Skip to content

Commit ac4d9a6

Browse files
committed
Allow for Html and css stores to be purged
1 parent 4191ab5 commit ac4d9a6

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

src/CssFromHTMLExtractor.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,24 @@ public function addHtmlToStore($rawHtml)
172172
{
173173
$this->htmlStore->addHtmlSnippet($rawHtml);
174174
}
175+
176+
/**
177+
* @return $this
178+
*/
179+
public function purgeHtmlStore()
180+
{
181+
$this->htmlStore->purge();
182+
183+
return $this;
184+
}
185+
186+
/**
187+
* @return $this
188+
*/
189+
public function purgeCssStore()
190+
{
191+
$this->cssStore->purge();
192+
193+
return $this;
194+
}
175195
}

src/CssStore.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ public function getStyles()
2525
return $this->styles;
2626
}
2727

28+
/**
29+
* @return $this
30+
*/
31+
public function purge()
32+
{
33+
$this->styles = [];
34+
35+
return $this;
36+
}
37+
2838
/**
2939
* @param string $path
3040
*

src/HtmlStore.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,14 @@ public function getSnippets()
1717
{
1818
return $this->snippets;
1919
}
20+
21+
/**
22+
* @return $this
23+
*/
24+
public function purge()
25+
{
26+
$this->snippets = [];
27+
28+
return $this;
29+
}
2030
}

src/Twig/Extension.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,15 @@ public function buildCriticalCssFromSnippets()
5353
{
5454
return $this->pageSpecificCssService->buildExtractedRuleSet();
5555
}
56+
57+
public function purgeHtmlStore()
58+
{
59+
$this->pageSpecificCssService->purgeHtmlStore();
60+
61+
}
62+
63+
public function purgeCssStore()
64+
{
65+
$this->pageSpecificCssService->purgeCssStore();
66+
}
5667
}

0 commit comments

Comments
 (0)