1 | <?php |
||
13 | class DoctrineCrudGenerator extends Generator |
||
14 | { |
||
15 | /** |
||
16 | * @var Filesystem |
||
17 | */ |
||
18 | protected $filesystem; |
||
19 | |||
20 | /** |
||
21 | * @var BundleStructureHelper |
||
22 | */ |
||
23 | protected $helper; |
||
24 | |||
25 | /** @var BundleInterface */ |
||
26 | protected $bundle; |
||
27 | |||
28 | protected $entity; |
||
29 | protected $metadata; |
||
30 | protected $actions; |
||
31 | |||
32 | /** |
||
33 | * Constructor. |
||
34 | * |
||
35 | * @param Filesystem $filesystem A Filesystem instance |
||
36 | * @param BundleInterface $bundle |
||
37 | * @param string $entity |
||
38 | */ |
||
39 | 5 | public function __construct(Filesystem $filesystem, BundleInterface $bundle, $entity) |
|
44 | |||
45 | /** |
||
46 | * Generate the CRUD controller. |
||
47 | * |
||
48 | * @param BundleInterface $bundle A bundle object |
||
49 | * @param string $entity The entity relative class name |
||
50 | * @param ClassMetadataInfo $metadata The entity class metadata |
||
51 | * @param array $needWriteActions Whether or not to generate write actions |
||
52 | * @param $forceOverwrite |
||
53 | */ |
||
54 | 5 | public function generate( |
|
76 | |||
77 | /** |
||
78 | * Generates the controller class only. |
||
79 | * |
||
80 | * @param bool $forceOverwrite |
||
81 | */ |
||
82 | 4 | protected function generateControllerClass($forceOverwrite) |
|
110 | |||
111 | /** |
||
112 | * Generates the functional test class only. |
||
113 | */ |
||
114 | 3 | protected function generateTestClass() |
|
124 | |||
125 | 3 | protected function canWriteToFile($file, $forceOverwrite) |
|
129 | |||
130 | /** |
||
131 | * @param ClassMetadataInfo $metadata |
||
132 | * |
||
133 | * @throws \InvalidArgumentException |
||
134 | * |
||
135 | * @return string |
||
136 | */ |
||
137 | 3 | private function getIdentifierType(ClassMetadataInfo $metadata) |
|
148 | |||
149 | /** |
||
150 | * @param ClassMetadataInfo $metadata |
||
151 | * |
||
152 | * @return mixed |
||
153 | */ |
||
154 | 3 | private function getEntityIdentifier(ClassMetadataInfo $metadata) |
|
158 | |||
159 | /** |
||
160 | * @param string $idType |
||
161 | * |
||
162 | * @return string |
||
163 | */ |
||
164 | 3 | private function getRequirementRegex($idType) |
|
175 | } |
||
176 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: