InlineConstraint.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. /**
  17. * {@inheritDoc}
  18. */
  19. public function validatedBy()
  20. {
  21. return 'sonata.admin.validator.inline';
  22. }
  23. /**
  24. * @return bool
  25. */
  26. public function isClosure()
  27. {
  28. return $this->method instanceof \Closure;
  29. }
  30. /**
  31. * @return mixed
  32. */
  33. public function getClosure()
  34. {
  35. return $this->method;
  36. }
  37. /**
  38. * {@inheritDoc}
  39. */
  40. public function getTargets()
  41. {
  42. return self::CLASS_CONSTRAINT;
  43. }
  44. /**
  45. * {@inheritDoc}
  46. */
  47. public function getRequiredOptions()
  48. {
  49. return array(
  50. 'service',
  51. 'method'
  52. );
  53. }
  54. /**
  55. * @return string
  56. */
  57. public function getMethod()
  58. {
  59. return $this->method;
  60. }
  61. /**
  62. * @return mixed
  63. */
  64. public function getService()
  65. {
  66. return $this->service;
  67. }
  68. }