1 | <?php |
||
18 | abstract class Component implements |
||
19 | ComponentInterface, |
||
20 | WithNavigation |
||
21 | { |
||
22 | use HasAccess, HasEvents, HasNavigation; |
||
23 | |||
24 | /** |
||
25 | * @var |
||
26 | */ |
||
27 | protected $name; |
||
28 | |||
29 | /** |
||
30 | * @var \Illuminate\Foundation\Application |
||
31 | */ |
||
32 | protected $app; |
||
33 | |||
34 | /** |
||
35 | * The component display name |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $title; |
||
40 | |||
41 | /** |
||
42 | * @var mixed|\Sco\Admin\Contracts\RepositoryInterface |
||
43 | */ |
||
44 | protected $repository; |
||
45 | |||
46 | /** |
||
47 | * @var \Illuminate\Database\Eloquent\Model |
||
48 | */ |
||
49 | protected $model; |
||
50 | |||
51 | protected static $booted = []; |
||
52 | |||
53 | /** |
||
54 | * @var \Illuminate\Contracts\Events\Dispatcher |
||
55 | */ |
||
56 | protected static $dispatcher; |
||
57 | |||
58 | abstract public function model(); |
||
59 | |||
60 | public function __construct(Application $app, RepositoryInterface $repository) |
||
61 | { |
||
62 | $this->app = $app; |
||
63 | $this->repository = $repository; |
||
64 | |||
65 | $this->makeModel(); |
||
66 | |||
67 | $this->repository->setModel($this->getModel()); |
||
68 | |||
69 | if (!$this->name) { |
||
70 | $this->setDefaultName(); |
||
71 | } |
||
72 | |||
73 | $this->bootIfNotBooted(); |
||
74 | } |
||
75 | |||
76 | protected function setDefaultName() |
||
80 | |||
81 | /** |
||
82 | * @return string |
||
83 | */ |
||
84 | protected function getModelClassName() |
||
94 | |||
95 | protected function makeModel() |
||
121 | |||
122 | public function getName() |
||
126 | |||
127 | public function getTitle() |
||
131 | |||
132 | public function getModel() |
||
136 | |||
137 | public function getRepository() |
||
141 | |||
142 | /** |
||
143 | * {@inheritdoc} |
||
144 | */ |
||
145 | public function getConfigs() |
||
155 | |||
156 | /** |
||
157 | * {@inheritdoc} |
||
158 | */ |
||
159 | public function fireView() |
||
178 | |||
179 | public function get() |
||
187 | |||
188 | /** |
||
189 | * {@inheritdoc} |
||
190 | */ |
||
191 | public function fireCreate() |
||
211 | |||
212 | /** |
||
213 | * {@inheritdoc} |
||
214 | */ |
||
215 | public function store() |
||
221 | |||
222 | /** |
||
223 | * {@inheritdoc} |
||
224 | */ |
||
225 | public function fireEdit($id) |
||
248 | |||
249 | /** |
||
250 | * {@inheritdoc} |
||
251 | */ |
||
252 | public function update($id) |
||
257 | |||
258 | public function delete($id) |
||
263 | |||
264 | public function forceDelete($id) |
||
269 | |||
270 | public function restore($id) |
||
275 | |||
276 | protected function bootIfNotBooted() |
||
288 | |||
289 | /** |
||
290 | * The "booting" method of the model. |
||
291 | * |
||
292 | * @return void |
||
293 | */ |
||
294 | protected function boot() |
||
298 | |||
299 | /** |
||
300 | * Boot all of the bootable traits on the model. |
||
301 | * |
||
302 | * @return void |
||
303 | */ |
||
304 | protected function bootTraits() |
||
312 | } |
||
313 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.