InlineConstraint.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  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 Sonata\AdminBundle\Validator\Constraints;
  11. use Symfony\Component\Validator\Constraint;
  12. class InlineConstraint extends Constraint
  13. {
  14. protected $service;
  15. protected $method;
  16. public function validatedBy()
  17. {
  18. return 'sonata.admin.validator.inline';
  19. }
  20. public function isClosure()
  21. {
  22. return $this->method instanceof \Closure;
  23. }
  24. public function getClosure()
  25. {
  26. return $this->method;
  27. }
  28. /**
  29. * {@inheritDoc}
  30. */
  31. public function getTargets()
  32. {
  33. return self::CLASS_CONSTRAINT;
  34. }
  35. public function getRequiredOptions()
  36. {
  37. return array(
  38. 'service',
  39. 'method'
  40. );
  41. }
  42. public function getMethod()
  43. {
  44. return $this->method;
  45. }
  46. public function getService()
  47. {
  48. return $this->service;
  49. }
  50. }