1 | <?php |
||
20 | abstract class SolrReindexQueuedJobBase implements QueuedJob |
||
21 | { |
||
22 | /** |
||
23 | * Flag whether this job is done |
||
24 | * |
||
25 | * @var bool |
||
26 | */ |
||
27 | protected $isComplete; |
||
28 | |||
29 | /** |
||
30 | * List of messages |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $messages; |
||
35 | |||
36 | /** |
||
37 | * Logger to use for this job |
||
38 | * |
||
39 | * @var LoggerInterface |
||
40 | */ |
||
41 | protected $logger; |
||
42 | |||
43 | public function __construct() |
||
48 | |||
49 | /** |
||
50 | * @return SearchLogFactory |
||
51 | */ |
||
52 | protected function getLoggerFactory() |
||
56 | |||
57 | /** |
||
58 | * Gets a logger for this job |
||
59 | * |
||
60 | * @return LoggerInterface |
||
61 | */ |
||
62 | protected function getLogger() |
||
74 | |||
75 | /** |
||
76 | * Assign custom logger for this job |
||
77 | * |
||
78 | * @param LoggerInterface $logger |
||
79 | */ |
||
80 | public function setLogger($logger) |
||
84 | |||
85 | public function getJobData() |
||
99 | |||
100 | public function setJobData($totalSteps, $currentStep, $isComplete, $jobData, $messages) |
||
105 | |||
106 | /** |
||
107 | * Get the reindex handler |
||
108 | * |
||
109 | * @return SolrReindexHandler |
||
110 | */ |
||
111 | protected function getHandler() |
||
115 | |||
116 | public function jobFinished() |
||
120 | |||
121 | public function prepareForRestart() |
||
125 | |||
126 | public function setup() |
||
130 | |||
131 | public function afterComplete() |
||
135 | |||
136 | public function getJobType() |
||
140 | |||
141 | public function getSignature() |
||
145 | |||
146 | public function addMessage($message) |
||
150 | } |
||
151 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.