ChoiceView.php 1.1 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 choice in templates.
  13. *
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. */
  16. class ChoiceView
  17. {
  18. public $label;
  19. public $value;
  20. public $data;
  21. /**
  22. * Additional attributes for the HTML tag.
  23. */
  24. public $attr;
  25. /**
  26. * Creates a new choice view.
  27. *
  28. * @param mixed $data The original choice
  29. * @param string $value The view representation of the choice
  30. * @param string|false $label The label displayed to humans; pass false to discard the label
  31. * @param array $attr Additional attributes for the HTML tag
  32. */
  33. public function __construct($data, string $value, $label, array $attr = [])
  34. {
  35. $this->data = $data;
  36. $this->value = $value;
  37. $this->label = $label;
  38. $this->attr = $attr;
  39. }
  40. }