Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixing an issue with the lineage parsing logic to account for instanc…
…es where the matched pattern might be hidden (and subsequently not match properly)
  • Loading branch information
bolt-bot committed Dec 1, 2016
commit 7018eff1c8c00ea383ad050e240d9cb91af9f756
24 changes: 17 additions & 7 deletions src/PatternLab/PatternData/Helpers/LineageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ public function run() {
//Grab the template extension getting used so we can strip it off down below.
$patternExtension = Config::getOption("patternExtension");

//Store the length of our broken up path for reference below
$length = count($lineageParts);

//Strip off the @ sign at the beginning of our $lineage string.
$lineage = ltrim($lineage, '@');

//Break apart the full lineage path based on any slashes that may exist.
$lineageParts = explode('/', $lineage);

//Store the length of our broken up path for reference below
$length = count($lineageParts);

//Store the first part of the string up to the first slash "/"
$patternType = $lineageParts[0];

Expand All @@ -79,9 +80,18 @@ public function run() {
//Remove any potential prefixed numbers or number + dash combos on our Pattern Name.
$patternName = preg_replace('/^[0-9\-]+/', '', $patternName);

//Strip off the pattern path extension (.twig, .mustache, etc)
$patternName = explode('.' . $patternExtension, $patternName);
$patternName = $patternName[0];
//Flag any "_" hidden patterns so we skip over for now.
if ($patternName[0] == '_'){
$hidden = true;
}

//Strip off the pattern path extension (.twig, .mustache, etc) if it exists.
$patternNameStripped = explode('.' . $patternExtension, $patternName);

// If the pattern name parsed had an extension, re-assign our Pattern Name to that.
if (count($patternNameStripped) > 1){
$patternName = $patternNameStripped[0];
}

//Finally, re-assign $lineage to the default PL pattern key.
$lineage = $patternType . "-" . $patternName;
Expand All @@ -94,7 +104,7 @@ public function run() {

} else {

if (strpos($lineage, '/') === false) {
if (strpos($lineage, '/') === false && !$hidden) {
$fileName = $patternStoreData["pathName"].".".$patternExtension;
Console::writeWarning("you may have a typo in ".$fileName.". `".$lineage."` is not a valid pattern...");
}
Expand Down