1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* BEdita, API-first content management framework |
6
|
|
|
* Copyright 2020 ChannelWeb Srl, Chialab Srl |
7
|
|
|
* |
8
|
|
|
* This file is part of BEdita: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Lesser General Public License as published |
10
|
|
|
* by the Free Software Foundation, either version 3 of the License, or |
11
|
|
|
* (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* See LICENSE.LGPL or <http://gnu.org/licenses/lgpl-3.0.html> for more details. |
14
|
|
|
*/ |
15
|
|
|
namespace BEdita\WebTools; |
16
|
|
|
|
17
|
|
|
use BEdita\WebTools\Command\CacheClearallCommand; |
18
|
|
|
use Cake\Console\CommandCollection; |
19
|
|
|
use Cake\Core\BasePlugin; |
20
|
|
|
use Cake\Core\PluginApplicationInterface; |
21
|
|
|
use Cake\Http\BaseApplication; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Plugin class for BEdita\WebTools. |
25
|
|
|
*/ |
26
|
|
|
class Plugin extends BasePlugin |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Load routes or not |
30
|
|
|
* |
31
|
|
|
* @var bool |
32
|
|
|
*/ |
33
|
|
|
protected bool $routesEnabled = false; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Use `cache clear_all` from BEdita\WebTools\Command\CacheClearallCommand |
37
|
|
|
* |
38
|
|
|
* @param \Cake\Console\CommandCollection $commands Console commands. |
39
|
|
|
* @return \Cake\Console\CommandCollection |
40
|
|
|
*/ |
41
|
|
|
public function console(CommandCollection $commands): CommandCollection |
42
|
|
|
{ |
43
|
|
|
parent::console($commands); |
44
|
|
|
$commands->remove('cache clear_all'); |
45
|
|
|
$commands->add('cache clear_all', CacheClearallCommand::class); |
46
|
|
|
|
47
|
|
|
return $commands; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @inheritDoc |
52
|
|
|
*/ |
53
|
|
|
public function bootstrap(PluginApplicationInterface $app): void |
54
|
|
|
{ |
55
|
|
|
// Call parent to load bootstrap from files. |
56
|
|
|
parent::bootstrap($app); |
57
|
|
|
|
58
|
|
|
assert($app instanceof BaseApplication); |
59
|
|
|
|
60
|
|
|
// Load more plugins here |
61
|
|
|
if (!$app->getPlugins()->has('Cake/TwigView')) { |
62
|
|
|
$app->addPlugin('Cake/TwigView'); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|