Skip to content

Commit 6c122f8

Browse files
committed
tweaking static class calls in the exporters
1 parent c159463 commit 6c122f8

File tree

7 files changed

+57
-35
lines changed

7 files changed

+57
-35
lines changed

src/PatternLab/PatternData/Exporters/DataLinkExporter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@
1818

1919
class DataLinkExporter extends \PatternLab\PatternData\Exporter {
2020

21+
protected $store;
22+
2123
public function __construct($options = array()) {
2224

2325
parent::__construct($options);
2426

27+
$this->store = PatternData::get();
28+
2529
}
2630

2731
public function run() {
2832

29-
$store = PatternData::get();
30-
foreach ($store as $patternStoreKey => $patternStoreData) {
33+
foreach ($this->store as $patternStoreKey => $patternStoreData) {
3134

3235
if ($patternStoreData["category"] == "pattern") {
3336

src/PatternLab/PatternData/Exporters/DataMergeExporter.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,42 @@
1818
use \PatternLab\Timer;
1919

2020
class DataMergeExporter extends \PatternLab\PatternData\Exporter {
21-
21+
22+
protected $store;
23+
2224
public function __construct($options = array()) {
23-
25+
2426
parent::__construct($options);
25-
27+
28+
$this->store = PatternData::get();
29+
2630
}
27-
31+
2832
public function run() {
29-
30-
$store = PatternData::get();
31-
foreach ($store as $patternStoreKey => $patternStoreData) {
32-
33+
34+
foreach ($this->store as $patternStoreKey => $patternStoreData) {
35+
3336
if ($patternStoreData["category"] == "pattern") {
34-
37+
3538
if (isset($patternStoreData["data"]) || isset($patternStoreData["listItems"])) {
3639
Data::initPattern($patternStoreKey);
3740
}
38-
41+
3942
if (isset($patternStoreData["data"])) {
4043
Data::setPatternData($patternStoreKey, $patternStoreData["data"]);
4144
}
42-
45+
4346
if (isset($patternStoreData["listItems"])) {
4447
Data::setPatternListItems($patternStoreKey, $patternStoreData["listItems"]);
4548
}
46-
49+
4750
}
48-
51+
4952
}
50-
53+
5154
// walk across the data and change link.pattern-partial to real source
5255
Data::compareReplaceListVarsInit();
53-
56+
5457
}
5558

5659
}

src/PatternLab/PatternData/Exporters/NavItemsExporter.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@
1818

1919
class NavItemsExporter extends \PatternLab\PatternData\Exporter {
2020

21+
protected $store;
22+
protected $styleGuideExcludes;
23+
2124
public function __construct($options = array()) {
2225

2326
parent::__construct($options);
2427

28+
$this->store = PatternData::get();
29+
$this->styleGuideExcludes = Config::getOption("styleGuideExcludes");
30+
2531
}
2632

2733
public function run() {
@@ -36,8 +42,7 @@ public function run() {
3642
$navItems["patternTypes"] = array();
3743

3844
// iterate over the different categories and add them to the navigation
39-
$store = PatternData::get();
40-
foreach ($store as $patternStoreKey => $patternStoreData) {
45+
foreach ($this->store as $patternStoreKey => $patternStoreData) {
4146

4247
if ($patternStoreData["category"] == "patternType") {
4348

@@ -96,17 +101,14 @@ public function run() {
96101

97102
}
98103

99-
// default vars
100-
$styleGuideExcludes = Config::getOption("styleGuideExcludes");
101-
102104
// review each subtype. add a view all link or remove the subtype as necessary
103105
foreach ($navItems["patternTypes"] as $patternTypeKey => $patternTypeValues) {
104106

105107
$reset = false;
106108
$patternType = $patternTypeValues["patternType"];
107109
$patternTypeDash = $patternTypeValues["patternTypeDash"];
108110

109-
if (!in_array($patternType,$styleGuideExcludes)) {
111+
if (!in_array($patternType,$this->styleGuideExcludes)) {
110112

111113
foreach ($patternTypeValues["patternTypeItems"] as $patternSubtypeKey => $patternSubtypeValues) {
112114

src/PatternLab/PatternData/Exporters/PatternPartialsExporter.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,16 @@
1919

2020
class PatternPartialsExporter extends \PatternLab\PatternData\Exporter {
2121

22+
protected $store;
23+
protected $cacheBuster;
24+
protected $styleGuideExcludes;
25+
2226
public function __construct($options = array()) {
2327

2428
parent::__construct($options);
29+
$this->store = PatternData::get();
30+
$this->cacheBuster = Data::getOption("cacheBuster");
31+
$this->styleGuideExcludes = Config::getOption("styleGuideExcludes");
2532

2633
}
2734

@@ -37,12 +44,10 @@ public function run($type = "", $subtype = "") {
3744

3845
// default vars
3946
$patternPartials = array();
40-
$styleGuideExcludes = Config::getOption("styleGuideExcludes");
4147

42-
$store = PatternData::get();
43-
foreach ($store as $patternStoreKey => $patternStoreData) {
48+
foreach ($this->store as $patternStoreKey => $patternStoreData) {
4449

45-
if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && (!$patternStoreData["hidden"]) && (!$patternStoreData["noviewall"]) && ($patternStoreData["depth"] > 1) && (!in_array($patternStoreData["type"],$styleGuideExcludes))) {
50+
if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && (!$patternStoreData["hidden"]) && (!$patternStoreData["noviewall"]) && ($patternStoreData["depth"] > 1) && (!in_array($patternStoreData["type"],$this->styleGuideExcludes))) {
4651

4752
if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["subtype"] == $subtype))) {
4853

@@ -81,7 +86,7 @@ public function run($type = "", $subtype = "") {
8186

8287
}
8388

84-
} else if (($patternStoreData["category"] == "patternSubtype") && (!in_array($patternStoreData["type"],$styleGuideExcludes))) {
89+
} else if (($patternStoreData["category"] == "patternSubtype") && (!in_array($patternStoreData["type"],$this->styleGuideExcludes))) {
8590

8691
if ((($patternStoreData["type"] == $type) && empty($subtype)) || (empty($type) && empty($subtype)) || (($patternStoreData["type"] == $type) && ($patternStoreData["name"] == $subtype))) {
8792

@@ -100,7 +105,7 @@ public function run($type = "", $subtype = "") {
100105

101106
}
102107

103-
return array("partials" => $patternPartials, "cacheBuster" => Data::getOption("cacheBuster"));
108+
return array("partials" => $patternPartials, "cacheBuster" => $this->cacheBuster);
104109

105110
}
106111

src/PatternLab/PatternData/Exporters/PatternPathDestsExporter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,21 @@
1818

1919
class PatternPathDestsExporter extends \PatternLab\PatternData\Exporter {
2020

21+
protected $store;
22+
2123
public function __construct($options = array()) {
2224

2325
parent::__construct($options);
2426

27+
$this->store = PatternData::get();
28+
2529
}
2630

2731
public function run() {
2832

2933
$patternPathDests = array();
3034

31-
$store = PatternData::get();
32-
foreach ($store as $patternStoreKey => $patternStoreData) {
35+
foreach ($this->store as $patternStoreKey => $patternStoreData) {
3336

3437
if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["hidden"]) && !$patternStoreData["hidden"]) {
3538

src/PatternLab/PatternData/Exporters/PatternPathSrcExporter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,21 @@
1919

2020
class PatternPathSrcExporter extends \PatternLab\PatternData\Exporter {
2121

22+
protected $store;
23+
2224
public function __construct($options = array()) {
2325

2426
parent::__construct($options);
2527

28+
$this->store = PatternData::get();
29+
2630
}
2731

2832
public function run() {
2933

3034
$patternPathDests = array();
3135

32-
$store = PatternData::get();
33-
foreach ($store as $patternStoreKey => $patternStoreData) {
36+
foreach ($this->store as $patternStoreKey => $patternStoreData) {
3437

3538
if (($patternStoreData["category"] == "pattern") && isset($patternStoreData["nameDash"])) {
3639

src/PatternLab/PatternData/Exporters/ViewAllPathsExporter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,27 @@
1818

1919
class ViewAllPathsExporter extends \PatternLab\PatternData\Exporter {
2020

21+
protected $styleGuideExcludes;
22+
2123
public function __construct($options = array()) {
2224

2325
parent::__construct($options);
2426

27+
$this->styleGuideExcludes = Config::getOption("styleGuideExcludes");
28+
2529
}
2630

2731
public function run($navItems) {
2832

2933
// default vars
3034
$viewAllPaths = array();
31-
$styleGuideExcludes = Config::getOption("styleGuideExcludes");
3235

3336
foreach ($navItems["patternTypes"] as $patternTypeKey => $patternTypeValues) {
3437

3538
$patternType = $patternTypeValues["patternType"];
3639
$patternTypeDash = $patternTypeValues["patternTypeDash"];
3740

38-
if (!in_array($patternType,$styleGuideExcludes)) {
41+
if (!in_array($patternType,$this->styleGuideExcludes)) {
3942

4043
foreach ($patternTypeValues["patternTypeItems"] as $patternSubtypeKey => $patternSubtypeValues) {
4144

0 commit comments

Comments
 (0)