1 | <?php |
||
30 | trait ImportableAdminTrait |
||
31 | { |
||
32 | /** |
||
33 | * Options to set to the form (ie, validation_groups). |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $formOptions = []; |
||
38 | /** |
||
39 | * @var Form |
||
40 | */ |
||
41 | private $importForm; |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | abstract public function getClass(); |
||
47 | |||
48 | /** |
||
49 | * @return Pool |
||
50 | */ |
||
51 | abstract public function getConfigurationPool(); |
||
52 | |||
53 | /** |
||
54 | * @return FormContractorInterface |
||
55 | */ |
||
56 | abstract public function getFormContractor(); |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | * |
||
61 | * @throws \ReflectionException |
||
62 | */ |
||
63 | public function getImportFormBuilder(array $headers) |
||
82 | |||
83 | /** |
||
84 | * @param FormBuilderInterface $formBuilder |
||
85 | * @param array $headers |
||
86 | * todo: use defineFormBuilder for import Action and upload Action |
||
87 | */ |
||
88 | public function defineImportFormBuilder(FormBuilderInterface $formBuilder, array $headers) |
||
135 | |||
136 | /** |
||
137 | * @param $admin |
||
138 | * @param null $object |
||
139 | * @return mixed |
||
140 | */ |
||
141 | public function configureActionButtons($admin, $object = null) |
||
149 | |||
150 | /** |
||
151 | * @param array $headers |
||
152 | * @return Form |
||
153 | * @throws \ReflectionException |
||
154 | */ |
||
155 | public function getImportForm(array $headers) |
||
160 | |||
161 | /** |
||
162 | * @param StepAggregator $workflow |
||
163 | */ |
||
164 | public function configureImportSteps(StepAggregator $workflow) |
||
182 | |||
183 | /** |
||
184 | * This method can be overloaded in your Admin service. |
||
185 | * It's called from importAction. |
||
186 | * |
||
187 | * @param Request $request |
||
188 | * @param Form $form |
||
189 | * |
||
190 | * @return Response|null |
||
191 | */ |
||
192 | public function preImport(Request $request, Form $form) |
||
195 | |||
196 | /** |
||
197 | * This method can be overloaded in your Admin service. |
||
198 | * It's called from importAction. |
||
199 | * |
||
200 | * @param Request $request |
||
201 | * @param UploadedFile $file |
||
202 | * @param Form $form |
||
203 | * @param mixed $results |
||
204 | * |
||
205 | * @return Response|null |
||
206 | */ |
||
207 | public function postImport(Request $request, UploadedFile $file, Form $form, $results) |
||
210 | |||
211 | /** |
||
212 | * @param FormMapper $formMapper |
||
213 | */ |
||
214 | abstract protected function configureImportFields(FormMapper $formMapper); |
||
215 | |||
216 | /** |
||
217 | * Attach the inline validator to the model metadata, this must be done once per admin. |
||
218 | */ |
||
219 | abstract protected function attachInlineValidator(); |
||
220 | |||
221 | /** |
||
222 | * @param RouteCollection $collection |
||
223 | */ |
||
224 | protected function configureRoutes(RouteCollection $collection) |
||
232 | |||
233 | /** |
||
234 | * @param array $headers |
||
235 | * @throws \ReflectionException |
||
236 | */ |
||
237 | protected function buildImportForm(array $headers) |
||
244 | |||
245 | /** |
||
246 | * @param $input |
||
247 | * @param $words |
||
248 | * @param TranslatorInterface $trans |
||
249 | * @param string $domain |
||
250 | * @return string |
||
251 | */ |
||
252 | private function nearest($input, $words, TranslatorInterface $trans, $domain = null) |
||
277 | } |
||
278 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.