FormEvent.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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;
  11. use Symfony\Contracts\EventDispatcher\Event;
  12. /**
  13. * @author Bernhard Schussek <bschussek@gmail.com>
  14. */
  15. class FormEvent extends Event
  16. {
  17. private $form;
  18. protected $data;
  19. /**
  20. * @param mixed $data The data
  21. */
  22. public function __construct(FormInterface $form, $data)
  23. {
  24. $this->form = $form;
  25. $this->data = $data;
  26. }
  27. /**
  28. * Returns the form at the source of the event.
  29. *
  30. * @return FormInterface
  31. */
  32. public function getForm()
  33. {
  34. return $this->form;
  35. }
  36. /**
  37. * Returns the data associated with this event.
  38. *
  39. * @return mixed
  40. */
  41. public function getData()
  42. {
  43. return $this->data;
  44. }
  45. /**
  46. * Allows updating with some filtered data.
  47. *
  48. * @param mixed $data
  49. */
  50. public function setData($data)
  51. {
  52. $this->data = $data;
  53. }
  54. }