Skip to content

Commit 6ea1016

Browse files
committed
adding support for configuring lineage options in the config
1 parent f70bef1 commit 6ea1016

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/PatternLab/PatternData/Helpers/LineageHelper.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@
1919

2020
class LineageHelper extends \PatternLab\PatternData\Helper {
2121

22+
protected $lineageMatch;
23+
protected $lineageMatchKey;
24+
2225
public function __construct($options = array()) {
2326

2427
parent::__construct($options);
2528

29+
$this->lineageMatch = Config::getOption("lineageMatch");
30+
$this->lineageMatchKey = Config::getOption("lineageMatchKey");
31+
2632
}
2733

2834
public function run() {
@@ -160,14 +166,13 @@ public function run() {
160166

161167
/**
162168
* Get the lineage for a given pattern by parsing it and matching mustache partials
163-
* @param {String} the filename for the pattern to be parsed
169+
* @param {String} the data from the raw pattern
164170
*
165171
* @return {Array} a list of patterns
166172
*/
167-
protected function findLineages($filename) {
168-
$data = file_get_contents($filename);
169-
if (preg_match_all('/{{>([ ]+)?([A-Za-z0-9-_]+)(?:\:[A-Za-z0-9-]+)?(?:(| )\(.*)?([ ]+)?}}/',$data,$matches)) {
170-
return array_unique($matches[2]);
173+
protected function findLineages($data) {
174+
if (preg_match_all("/".$this->lineageMatch."/",$data,$matches)) {
175+
return array_unique($matches[$this->lineageMatchKey]);
171176
}
172177
return array();
173178
}

0 commit comments

Comments
 (0)