From 81515360b9e600429afc13e8bb7a71961aacd19e Mon Sep 17 00:00:00 2001 From: Salem Ghoweri Date: Mon, 2 Oct 2017 16:10:49 -0400 Subject: [PATCH] fix: working fix to address PL referencing template paths to psuedo-patterns which don't exist. Addresses https://github.com/drupal-pattern-lab/patternlab-php-core/issues/22 --- src/PatternLab/Builder.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/PatternLab/Builder.php b/src/PatternLab/Builder.php index bceb8147..20cdc4fc 100644 --- a/src/PatternLab/Builder.php +++ b/src/PatternLab/Builder.php @@ -261,6 +261,20 @@ protected function generatePatterns($options = array()) { // modify the pattern mark-up $markup = $patternStoreData["code"]; $markupFull = $patternStoreData["header"].$markup.$patternStoreData["footer"]; + + + /** If the base template for a JSON / Yaml file (or psuedo pattern variation) lives in a different folder, + * use the `original` pattern's template instead. + * Fixes https://github.com/drupal-pattern-lab/patternlab-php-core/issues/22 + */ + if (!file_exists($patternSourceDir."/".$pathName.".".$patternExtension)){ + $originalPatternPathName = PatternData::getOption($patternStoreData["original"])["pathName"]; + if (file_exists($patternSourceDir."/".$originalPatternPathName.".".$patternExtension)){ + $pathName = $originalPatternPathName; + } + } + + $markupEngine = file_get_contents($patternSourceDir."/".$pathName.".".$patternExtension); // if the pattern directory doesn't exist create it