PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.2.89
WindPress – Tailwind CSS integration for WordPress v3.2.89
3.2.89 3.2.88 3.2.87 3.2.86 3.2.85 3.2.84 3.2.83 3.2.82 3.2.81 trunk 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 All 143 releases
← All changes | src/Integration/Timber/Compile.php +20 -17 3.0.163.2.89 View file →
@@ -13,34 +13,37 @@
13 13
14 14 use WindPressDeps\Symfony\Component\Finder\Finder;
15 15 use Timber\LocationManager;
16 16 use Timber\Timber;
17 +use WindPress\WindPress\Core\Scanner\FileScanner;
17 18 /**
18 19 * @author Joshua Gugun Siagian <suabahasa@gmail.com>
19 20 */
20 21 class Compile
21 22 {
22 - public function __invoke() : array
23 + /**
24 + * @param array $metadata
25 + */
26 + public function __invoke($metadata): array
23 27 {
24 - if (!\class_exists(Timber::class)) {
28 + if (!class_exists(Timber::class)) {
25 29 return [];
26 30 }
27 - return $this->get_contents();
31 + return $this->get_contents($metadata);
28 32 }
29 - public function get_contents() : array
33 + public function get_contents($metadata): array
30 34 {
31 - $contents = [];
32 - $paths = LocationManager::get_locations();
33 - $finder = new Finder();
34 - $finder->in($paths);
35 - $finder->files()->name('*.twig');
36 - \do_action('f!windpress/integration/timber/compile:get_contents.finder', $finder);
37 - foreach ($finder as $file) {
38 - $template_file = $file->getPathname();
39 - if (!\is_readable($template_file)) {
40 - continue;
35 + return FileScanner::scan_files('timber', static function (): \Generator {
36 + $paths = LocationManager::get_locations();
37 + $paths = array_unique(array_filter(array_merge(...array_values($paths)), static fn($path) => is_string($path) && $path !== '/' && is_dir($path)));
38 + if ($paths === []) {
39 + return;
41 40 }
42 - $contents[] = ['name' => $file->getRelativePathname(), 'content' => $file->getContents()];
43 - }
44 - return $contents;
41 + $finder = new Finder();
42 + $finder->in($paths)->files()->name('*.twig');
43 + do_action('a!windpress/integration/timber/compile:get_contents.finder', $finder);
44 + foreach ($finder as $file) {
45 + yield ['path' => $file->getPathname(), 'name' => $file->getRelativePathname()];
46 + }
47 + }, $metadata['next_batch'] ?? \false);
45 48 }
46 49 }