-
Notifications
You must be signed in to change notification settings - Fork 11
/
app.php
46 lines (33 loc) · 1.11 KB
/
app.php
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
#!/usr/bin/env php
<?php
use Symfony\Component\Console\Application;
use Symfony\Component\Finder\Finder;
// use SatCMS\Modules\Sat\Commands\TestCommand;
require "public/modules/core/loader.php";
$BOOT_OPTIONS = array(
loader::OPTION_TESTING => true,
loader::OPTION_NO_INIT => true,
loader::OPTION_CORE_PARAMS => array(
//'debug' => 1 //quite
)
);
loader::bootstrap($BOOT_OPTIONS);
$application = new Application();
$root = __DIR__ . '/src/*/Commands';
$finder = new Finder();
$finder->files()->in($root)->name('*.php')->depth('== 0');
$commands = [];
/** @var \SplFileInfo $file */
foreach ($finder as $file) {
// ... do something
preg_match('@(?<mod>\w+)[\\\/]Commands[\\\/](?<cmd>\w+)\.php$@', $file->getPathname(), $matches);
$commands []= 'SatCMS\\' . ucfirst($matches['mod'])
. '\\Commands\\' . ucfirst($matches['cmd']); // . 'Command';
}
foreach ($commands as $command) {
$check = new ReflectionClass($command);
if ($check && !$check->isAbstract()) {
$application->add(new $command);
}
}
$application->run();