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 +21 -22 3.0.63.2.89 View file →
@@ -10,41 +10,40 @@
10 10 */
11 11 declare (strict_types=1);
12 12 namespace WindPress\WindPress\Integration\Timber;
13 13
14 -use WindPressPackages\Symfony\Component\Finder\Finder;
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[] = [
43 - 'name' => $file->getRelativePathname(),
44 - // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Local file
45 - 'content' => \file_get_contents($template_file),
46 - ];
47 - }
48 - 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);
49 48 }
50 49 }