-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.php
More file actions
executable file
·57 lines (48 loc) · 1.22 KB
/
plugin.php
File metadata and controls
executable file
·57 lines (48 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace XeHub\XePlugin\XeCli;
use Illuminate\Filesystem\Filesystem;
use Xpressengine\Plugin\AbstractPlugin;
/**
* Class Plugin
*
* Xe Cli Plugin
*
* @package XeHub\XePlugin\XeCli
*/
final class Plugin extends AbstractPlugin
{
/** @var Filesystem */
protected $fileSystem;
/**
* Plugin __construct
*/
public function __construct()
{
parent::__construct();
$this->fileSystem = app(Filesystem::class);
}
/**
* @return void
*/
public function boot()
{
$this->registerConsoleCommands(__DIR__ . '/src/Console/Commands');
}
/**
* Register Console Commands
*
* @param string $commandsDirPath
*/
public function registerConsoleCommands(string $commandsDirPath)
{
$commandFiles = $this->fileSystem->files($commandsDirPath);
foreach ($commandFiles as $commandFile) {
$className = str_replace('.php', '', $commandFile->getFilename());
$commandClass = sprintf('%s\\Console\\Commands\\%s', __NAMESPACE__, $className);
if (method_exists($commandClass, 'register') === false) {
continue;
}
$commandClass::register();
}
}
}