ChoiceGroupView.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\ChoiceList\View;
  11. /**
  12. * Represents a group of choices in templates.
  13. *
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. */
  16. class ChoiceGroupView implements \IteratorAggregate
  17. {
  18. public $label;
  19. public $choices;
  20. /**
  21. * Creates a new choice group view.
  22. *
  23. * @param string $label The label of the group
  24. * @param ChoiceGroupView[]|ChoiceView[] $choices the choice views in the group
  25. */
  26. public function __construct($label, array $choices = array())
  27. {
  28. $this->label = $label;
  29. $this->choices = $choices;
  30. }
  31. /**
  32. * {@inheritdoc}
  33. *
  34. * @return self[]|ChoiceView[]
  35. */
  36. public function getIterator()
  37. {
  38. return new \ArrayIterator($this->choices);
  39. }
  40. }