ChoiceGroupView.php 965 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 ChoiceGroupView[]|ChoiceView[] $choices the choice views in the group
  24. */
  25. public function __construct(string $label, array $choices = [])
  26. {
  27. $this->label = $label;
  28. $this->choices = $choices;
  29. }
  30. /**
  31. * {@inheritdoc}
  32. *
  33. * @return self[]|ChoiceView[]
  34. */
  35. public function getIterator()
  36. {
  37. return new \ArrayIterator($this->choices);
  38. }
  39. }