Merge branch 'form-submit-2.2' into form-submit-2.3
Conflicts: src/Symfony/Component/Form/Util/VirtualFormAwareIterator.php
This commit is contained in:
commit
7a34d96dcd
78
src/Symfony/Component/Form/Util/ReferencingArrayIterator.php
Normal file
78
src/Symfony/Component/Form/Util/ReferencingArrayIterator.php
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Form\Util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterator that traverses an array.
|
||||||
|
*
|
||||||
|
* Contrary to {@link \ArrayIterator}, this iterator recognizes changes in the
|
||||||
|
* original array during iteration.
|
||||||
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class ReferencingArrayIterator implements \Iterator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new iterator.
|
||||||
|
*
|
||||||
|
* @param array $array An array
|
||||||
|
*/
|
||||||
|
public function __construct(array &$array)
|
||||||
|
{
|
||||||
|
$this->array = &$array;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*{@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function current()
|
||||||
|
{
|
||||||
|
return current($this->array);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*{@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function next()
|
||||||
|
{
|
||||||
|
next($this->array);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*{@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function key()
|
||||||
|
{
|
||||||
|
return key($this->array);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*{@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function valid()
|
||||||
|
{
|
||||||
|
return null !== key($this->array);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*{@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function rewind()
|
||||||
|
{
|
||||||
|
reset($this->array);
|
||||||
|
}
|
||||||
|
}
|
@ -14,8 +14,8 @@ namespace Symfony\Component\Form\Util;
|
|||||||
/**
|
/**
|
||||||
* Iterator that traverses an array of forms.
|
* Iterator that traverses an array of forms.
|
||||||
*
|
*
|
||||||
* Contrary to \ArrayIterator, this iterator recognizes changes in the original
|
* Contrary to {@link \ArrayIterator}, this iterator recognizes changes in the
|
||||||
* array during iteration.
|
* original array during iteration.
|
||||||
*
|
*
|
||||||
* You can wrap the iterator into a {@link \RecursiveIterator} in order to
|
* You can wrap the iterator into a {@link \RecursiveIterator} in order to
|
||||||
* enter any child form that inherits its parent's data and iterate the children
|
* enter any child form that inherits its parent's data and iterate the children
|
||||||
@ -26,68 +26,10 @@ namespace Symfony\Component\Form\Util;
|
|||||||
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use
|
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use
|
||||||
* {@link InheritDataAwareIterator} instead.
|
* {@link InheritDataAwareIterator} instead.
|
||||||
*/
|
*/
|
||||||
class VirtualFormAwareIterator implements \RecursiveIterator
|
class VirtualFormAwareIterator extends ReferencingArrayIterator implements \RecursiveIterator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Symfony\Component\Form\FormInterface[]
|
* {@inheritdoc}
|
||||||
*/
|
|
||||||
private $forms;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new iterator.
|
|
||||||
*
|
|
||||||
* @param \Symfony\Component\Form\FormInterface[] $forms An array of forms
|
|
||||||
*/
|
|
||||||
public function __construct(array &$forms)
|
|
||||||
{
|
|
||||||
// Uncomment this as soon as the deprecation note should be shown
|
|
||||||
// trigger_error('VirtualFormAwareIterator is deprecated since version 2.3 and will be removed in 3.0. Use InheritDataAwareIterator instead.', E_USER_DEPRECATED);
|
|
||||||
|
|
||||||
$this->forms = &$forms;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function current()
|
|
||||||
{
|
|
||||||
return current($this->forms);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function next()
|
|
||||||
{
|
|
||||||
next($this->forms);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function key()
|
|
||||||
{
|
|
||||||
return key($this->forms);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function valid()
|
|
||||||
{
|
|
||||||
return null !== key($this->forms);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function rewind()
|
|
||||||
{
|
|
||||||
reset($this->forms);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritdoc}
|
|
||||||
*/
|
*/
|
||||||
public function getChildren()
|
public function getChildren()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user