ChoiceView.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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\Extension\Core\View;
  11. /**
  12. * Represents a choice in templates.
  13. *
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. *
  16. * @deprecated since version 2.7, to be removed in 3.0.
  17. * Use {@link \Symfony\Component\Form\ChoiceList\View\ChoiceView} instead.
  18. */
  19. class ChoiceView
  20. {
  21. public $label;
  22. public $value;
  23. public $data;
  24. /**
  25. * Creates a new ChoiceView.
  26. *
  27. * @param mixed $data The original choice
  28. * @param string $value The view representation of the choice
  29. * @param string $label The label displayed to humans
  30. */
  31. public function __construct($data, $value, $label)
  32. {
  33. $this->data = $data;
  34. $this->value = $value;
  35. $this->label = $label;
  36. }
  37. }
  38. namespace Symfony\Component\Form\ChoiceList\View;
  39. use Symfony\Component\Form\Extension\Core\View\ChoiceView as LegacyChoiceView;
  40. /**
  41. * Represents a choice in templates.
  42. *
  43. * @author Bernhard Schussek <bschussek@gmail.com>
  44. */
  45. class ChoiceView extends LegacyChoiceView
  46. {
  47. /**
  48. * Additional attributes for the HTML tag.
  49. */
  50. public $attr;
  51. /**
  52. * Creates a new choice view.
  53. *
  54. * @param mixed $data The original choice
  55. * @param string $value The view representation of the choice
  56. * @param string $label The label displayed to humans
  57. * @param array $attr Additional attributes for the HTML tag
  58. */
  59. public function __construct($data, $value, $label, array $attr = array())
  60. {
  61. parent::__construct($data, $value, $label);
  62. $this->attr = $attr;
  63. }
  64. }