@@ 30-53 (lines=24) @@ | ||
27 | $this->rebuildCommandsCache($io); |
|
28 | } |
|
29 | ||
30 | final protected function rebuildBundlesCache(TaisiyaStyle $io) |
|
31 | { |
|
32 | $io->isVerbose() && $io->writeln('Rebuild bundles cache'); |
|
33 | ||
34 | $bundles = []; |
|
35 | ||
36 | $finder = Finder::create() |
|
37 | ->in(TAISIYA_ROOT) |
|
38 | ->path('/(src|vendor)/') |
|
39 | ->files() |
|
40 | ->name('*ServiceProvider.php'); |
|
41 | ||
42 | foreach ($finder as $k => $file) { |
|
43 | $bundleServiceProvider = $this->extractClassNameFromFile($file->getPathname()); |
|
44 | $reflectionClass = new \ReflectionClass($bundleServiceProvider); |
|
45 | if (!$reflectionClass->isAbstract() && $reflectionClass->isSubclassOf(ServiceProvider::class)) { |
|
46 | $io->isVerbose() && $io->writeln(' + '.$bundleServiceProvider); |
|
47 | $bundles[] = $bundleServiceProvider; |
|
48 | } |
|
49 | } |
|
50 | ||
51 | $this->putDataToCacheFile('bundles.cache.php', $bundles); |
|
52 | $io->isVerbose() && $io->writeln(' Bundles saved to <info>bundles.cache.php</info>'); |
|
53 | } |
|
54 | ||
55 | final protected function rebuildCommandsCache(TaisiyaStyle $io) |
|
56 | { |
|
@@ 55-82 (lines=28) @@ | ||
52 | $io->isVerbose() && $io->writeln(' Bundles saved to <info>bundles.cache.php</info>'); |
|
53 | } |
|
54 | ||
55 | final protected function rebuildCommandsCache(TaisiyaStyle $io) |
|
56 | { |
|
57 | $io->isVerbose() && $io->writeln('Rebuild commands cache'); |
|
58 | ||
59 | $commands = []; |
|
60 | ||
61 | $finder = Finder::create() |
|
62 | ->in(TAISIYA_ROOT) |
|
63 | ->path('/(src|vendor)/') |
|
64 | ->files() |
|
65 | ->name('*Command.php'); |
|
66 | ||
67 | foreach ($finder as $k => $file) { |
|
68 | $commandClass = $this->extractClassNameFromFile($file->getPathname()); |
|
69 | try { |
|
70 | $reflectionClass = new \ReflectionClass($commandClass); |
|
71 | } catch (\ReflectionException $e) { |
|
72 | continue; |
|
73 | } |
|
74 | if (!$reflectionClass->isAbstract() && $reflectionClass->isSubclassOf(Command::class)) { |
|
75 | $io->isVerbose() && $io->writeln(' + '.$commandClass); |
|
76 | $commands[] = $commandClass; |
|
77 | } |
|
78 | } |
|
79 | ||
80 | $this->putDataToCacheFile('commands.cache.php', $commands); |
|
81 | $io->isVerbose() && $io->writeln(' Commands saved to <info>commands.cache.php</info>'); |
|
82 | } |
|
83 | ||
84 | final protected function extractClassNameFromFile(string $filepath): string |
|
85 | { |