Conditions | 6 |
Paths | 8 |
Total Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
39 | public function provide(Application $app, ContainerInterface $container) |
||
40 | { |
||
41 | foreach (Glob::glob("{$this->dstDir}/*Command.php") as $file) { |
||
42 | $commands = []; |
||
43 | try { |
||
44 | $class = $this->namespace . pathinfo($file, PATHINFO_FILENAME); |
||
45 | $r = new \ReflectionClass($class); |
||
46 | if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) { |
||
47 | $command = $r->newInstance(); |
||
48 | $commands[] = $command; |
||
49 | } |
||
50 | } catch (\ReflectionException $e) { |
||
51 | // 忽略无法反射的命令 |
||
52 | } |
||
53 | $app->addCommands($commands); |
||
54 | } |
||
55 | } |
||
56 | } |