File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
src/PatternLab/PatternEngine/Twig/Loaders Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,22 @@ public function __construct($options = array()) {
4646 if (is_dir ($ layoutsPath )) {
4747 $ filesystemLoaderPaths [] = $ layoutsPath ;
4848 }
49-
49+
50+ // add source/_patterns subdirectories for Drupal theme template compatibility
51+ $ patternSourceDir = Config::getOption ("sourceDir " ).DIRECTORY_SEPARATOR ."_patterns " ;
52+ $ patternObjects = new \RecursiveIteratorIterator (new \RecursiveDirectoryIterator ($ patternSourceDir ), \RecursiveIteratorIterator::SELF_FIRST );
53+ $ patternObjects ->setFlags (\FilesystemIterator::SKIP_DOTS );
54+
55+ // sort the returned objects
56+ $ patternObjects = iterator_to_array ($ patternObjects );
57+ ksort ($ patternObjects );
58+
59+ foreach ($ patternObjects as $ name => $ object ) {
60+ if ($ object ->isDir ()) {
61+ $ filesystemLoaderPaths [] = $ object ->getPathname ();
62+ }
63+ }
64+
5065 // add the paths to the filesystem loader if the paths existed
5166 if (count ($ filesystemLoaderPaths ) > 0 ) {
5267 $ loaders [] = new \Twig_Loader_Filesystem ($ filesystemLoaderPaths );
You can’t perform that action at this time.
0 commit comments