Skip to content

Commit 000024c

Browse files
author
Evan Willhite
committed
search multiple paths using glob
1 parent 0f7837f commit 000024c

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/TwigExtension/ExtensionLoader.php

+10-11
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,18 @@ static public function get($type) {
4646
static protected function loadAll($type) {
4747
$theme = \Drupal::config('system.theme')->get('default');
4848
$themeLocation = drupal_get_path('theme', $theme);
49-
$fullPath = DRUPAL_ROOT . '/' . $themeLocation . '/' . 'pattern-lab/source/_twig-components/';
49+
$themePath = DRUPAL_ROOT . '/' . $themeLocation . '/';
5050

51-
$fullPathAlt = DRUPAL_ROOT . '/' . $themeLocation . '/' . 'components/_twig-components/';
51+
$extensionPaths = glob($themePath . '*/_twig-components/');
5252

53-
if (file_exists($fullPathAlt)){
54-
$fullPath = $fullPathAlt;
55-
}
56-
57-
foreach (scandir($fullPath . $type) as $file) {
58-
$fileInfo = pathinfo($file);
59-
if ($fileInfo['extension'] === 'php') {
60-
if ($file[0] != '.' && $file[0] != '_' && substr($file, 0, 3) != 'pl_') {
61-
static::load($type, $fullPath . $type . '/' . $file);
53+
foreach ($extensionPaths as $extensionPath) {
54+
$fullPath = $extensionPath;
55+
foreach (scandir($fullPath . $type) as $file) {
56+
$fileInfo = pathinfo($file);
57+
if ($fileInfo['extension'] === 'php') {
58+
if ($file[0] != '.' && $file[0] != '_' && substr($file, 0, 3) != 'pl_') {
59+
static::load($type, $fullPath . $type . '/' . $file);
60+
}
6261
}
6362
}
6463
}

0 commit comments

Comments
 (0)