mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-10 17:36:53 +00:00
fixed the join filter when several items have the same key
This commit is contained in:
@@ -489,7 +489,7 @@ function twig_array_merge($arr1, $arr2)
|
||||
function twig_join_filter($value, $glue = '')
|
||||
{
|
||||
if ($value instanceof Traversable) {
|
||||
$value = iterator_to_array($value);
|
||||
$value = iterator_to_array($value, false);
|
||||
}
|
||||
|
||||
return implode($glue, (array) $value);
|
||||
|
||||
@@ -114,20 +114,18 @@ function test_foo($value = 'foo')
|
||||
return $value;
|
||||
}
|
||||
|
||||
class Foo implements IteratorAggregate
|
||||
class Foo implements Iterator
|
||||
{
|
||||
const BAR_NAME = 'bar';
|
||||
|
||||
public $position = 0;
|
||||
public $array = array(1, 2);
|
||||
|
||||
public function bar($param1 = null, $param2 = null)
|
||||
{
|
||||
return 'bar'.($param1 ? '_'.$param1 : '').($param2 ? '-'.$param2 : '');
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayObject(array(1, 2));
|
||||
}
|
||||
|
||||
public function getFoo()
|
||||
{
|
||||
return 'foo';
|
||||
@@ -157,6 +155,31 @@ class Foo implements IteratorAggregate
|
||||
{
|
||||
return strtolower($value);
|
||||
}
|
||||
|
||||
public function rewind()
|
||||
{
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
public function current()
|
||||
{
|
||||
return $this->array[$this->position];
|
||||
}
|
||||
|
||||
public function key()
|
||||
{
|
||||
return 'a';
|
||||
}
|
||||
|
||||
public function next()
|
||||
{
|
||||
++$this->position;
|
||||
}
|
||||
|
||||
public function valid()
|
||||
{
|
||||
return isset($this->array[$this->position]);
|
||||
}
|
||||
}
|
||||
|
||||
class TestTokenParser_☃ extends Twig_TokenParser
|
||||
|
||||
Reference in New Issue
Block a user