VirtualFormAwareIterator.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Form\Util;
  11. /**
  12. * Iterator that traverses an array of forms.
  13. *
  14. * You can wrap the iterator into a {@link \RecursiveIterator} in order to
  15. * enter any child form that inherits its parent's data and iterate the children
  16. * of that form as well.
  17. *
  18. * @author Bernhard Schussek <bschussek@gmail.com>
  19. *
  20. * @deprecated since version 2.3, to be removed in 3.0.
  21. * Use {@link InheritDataAwareIterator} instead.
  22. */
  23. class VirtualFormAwareIterator extends \IteratorIterator implements \RecursiveIterator
  24. {
  25. public function __construct(\Traversable $iterator)
  26. {
  27. /*
  28. * Prevent to trigger deprecation notice when already using the
  29. * InheritDataAwareIterator class that extends this deprecated one.
  30. * The {@link Symfony\Component\Form\Util\InheritDataAwareIterator::__construct} method
  31. * forces this argument to false.
  32. */
  33. if (__CLASS__ === \get_class($this)) {
  34. @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Util\InheritDataAwareIterator class instead.', E_USER_DEPRECATED);
  35. }
  36. parent::__construct($iterator);
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function getChildren()
  42. {
  43. return new static($this->current());
  44. }
  45. /**
  46. *{@inheritdoc}
  47. */
  48. public function hasChildren()
  49. {
  50. return (bool) $this->current()->getConfig()->getInheritData();
  51. }
  52. }