1 | <?php |
||
42 | class ReIndexTaskAdditionalFieldProvider implements AdditionalFieldProviderInterface |
||
43 | { |
||
44 | |||
45 | /** |
||
46 | * Task information |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $taskInformation; |
||
51 | |||
52 | /** |
||
53 | * Scheduler task |
||
54 | * |
||
55 | * @var AbstractTask|ReIndexTask|NULL |
||
56 | */ |
||
57 | protected $task = null; |
||
58 | |||
59 | /** |
||
60 | * Scheduler Module |
||
61 | * |
||
62 | * @var SchedulerModuleController |
||
63 | */ |
||
64 | protected $schedulerModule; |
||
65 | |||
66 | /** |
||
67 | * Selected site |
||
68 | * |
||
69 | * @var Site |
||
70 | */ |
||
71 | protected $site = null; |
||
72 | |||
73 | /** |
||
74 | * @var PageRenderer |
||
75 | */ |
||
76 | protected $pageRenderer = null; |
||
77 | |||
78 | /** |
||
79 | * |
||
80 | * @param array $taskInfo |
||
81 | * @param \TYPO3\CMS\Scheduler\Task\AbstractTask|NULL $task |
||
82 | * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule |
||
83 | */ |
||
84 | protected function initialize( |
||
97 | |||
98 | /** |
||
99 | * Used to define fields to provide the Solr server address when adding |
||
100 | * or editing a task. |
||
101 | * |
||
102 | * @param array $taskInfo reference to the array containing the info used in the add/edit form |
||
103 | * @param AbstractTask $task when editing, reference to the current task object. Null when adding. |
||
104 | * @param SchedulerModuleController $schedulerModule reference to the calling object (Scheduler's BE module) |
||
105 | * @return array Array containing all the information pertaining to the additional fields |
||
106 | * The array is multidimensional, keyed to the task class name and each field's id |
||
107 | * For each field it provides an associative sub-array with the following: |
||
108 | */ |
||
109 | public function getAdditionalFields( |
||
136 | |||
137 | protected function getIndexingConfigurationSelector() |
||
155 | |||
156 | /** |
||
157 | * Checks any additional data that is relevant to this task. If the task |
||
158 | * class is not relevant, the method is expected to return TRUE |
||
159 | * |
||
160 | * @param array $submittedData reference to the array containing the data submitted by the user |
||
161 | * @param SchedulerModuleController $schedulerModule reference to the calling object (Scheduler's BE module) |
||
162 | * @return bool True if validation was ok (or selected class is not relevant), FALSE otherwise |
||
163 | */ |
||
164 | public function validateAdditionalFields( |
||
178 | |||
179 | /** |
||
180 | * Saves any additional input into the current task object if the task |
||
181 | * class matches. |
||
182 | * |
||
183 | * @param array $submittedData array containing the data submitted by the user |
||
184 | * @param AbstractTask $task reference to the current task object |
||
185 | */ |
||
186 | public function saveAdditionalFields( |
||
200 | |||
201 | /** |
||
202 | * @return PageRenderer |
||
203 | */ |
||
204 | protected function getPageRenderer() |
||
211 | |||
212 | /** |
||
213 | * Check that a task is an instance of ReIndexTask |
||
214 | * |
||
215 | * @param $task |
||
216 | * @throws \LogicException |
||
217 | */ |
||
218 | protected function isTaskInstanceofReIndexTask($task) |
||
227 | } |
||
228 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: