1 | <?php |
||
22 | abstract class AbstractCommand extends ContainerAwareCommand |
||
23 | { |
||
24 | /** |
||
25 | * An instance of Validator |
||
26 | * |
||
27 | * @var \Symfony\Component\Validator\Validator |
||
28 | */ |
||
29 | protected $validator; |
||
30 | |||
31 | /** |
||
32 | * Shortcut to return the Doctrine Registry service. |
||
33 | * |
||
34 | * @return \Doctrine\Bundle\DoctrineBundle\Registry |
||
35 | */ |
||
36 | protected function getDoctrine() |
||
40 | |||
41 | /** |
||
42 | * Shortcut to return an entity repository class. |
||
43 | * |
||
44 | * @return \Doctrine\ORM\EntityRepository |
||
45 | */ |
||
46 | protected function getRepository($name) |
||
50 | |||
51 | /** |
||
52 | * Shortcut to the translator method |
||
53 | * |
||
54 | * @param string $message |
||
55 | * @param array $params |
||
56 | */ |
||
57 | protected function trans($message, $params = []) |
||
61 | |||
62 | /** |
||
63 | * Writes an error message to the output and adds a newline at the end. |
||
64 | * |
||
65 | * @param OutputInterface $output |
||
66 | * @param string $message |
||
67 | * @param array $params |
||
68 | * |
||
69 | * @return mixed |
||
70 | */ |
||
71 | protected function error(OutputInterface $output, $message, $params = []) |
||
75 | |||
76 | /** |
||
77 | * Writes an success message to the output and adds a newline at the end. |
||
78 | * |
||
79 | * @param OutputInterface $output |
||
80 | * @param string $message |
||
81 | * @param array $params |
||
82 | * |
||
83 | * @return mixed |
||
84 | */ |
||
85 | protected function success(OutputInterface $output, $message, $params = []) |
||
89 | |||
90 | /** |
||
91 | * Get instance of Validator |
||
92 | * |
||
93 | * @return \Symfony\Component\Validator\Validator |
||
94 | */ |
||
95 | protected function getValidator() |
||
103 | |||
104 | /** |
||
105 | * Validate a property of an entity |
||
106 | * |
||
107 | * @param object $entity |
||
108 | * @param string $propertyName |
||
109 | * @param null $groups |
||
110 | * |
||
111 | * @return bool |
||
112 | */ |
||
113 | protected function validate($entity, $propertyName, $groups = null) |
||
122 | } |
||
123 |