Skip to content

Commit 3877d32

Browse files
committed
Switch code for faster execution
1 parent 4f0f850 commit 3877d32

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

src/ResourceManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function getFileHash($fullPath)
155155

156156
if($hash && function_exists('apcu_store'))
157157
{
158-
$res = apcu_store($key, $hash, 86400);
158+
apcu_store($key, $hash, 86400);
159159
}
160160

161161
return $hash;

src/Resources/AbstractDispatchableResource.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public function setContent($content)
4848
protected function _processContent()
4949
{
5050
if(isset($this->_manager)
51-
&& strpos($this->_content, '@' . 'do-not-dispatch') === false
52-
&& ValueAs::bool($this->getOption('dispatch', true)))
51+
&& ValueAs::bool($this->getOption('dispatch', false))
52+
&& strpos($this->_content, '@' . 'do-not-dispatch') === false)
5353
{
5454
$this->_dispatch();
5555
}
@@ -59,8 +59,8 @@ protected function _processContent()
5959

6060
//Return the raw content if minification has been disabled or @do-not-minify is set
6161
if(!$preMinified
62-
&& strpos($this->_content, '@' . 'do-not-minify') === false
63-
&& ValueAs::bool($this->getOption('minify', true)))
62+
&& ValueAs::bool($this->getOption('minify', false))
63+
&& strpos($this->_content, '@' . 'do-not-minify') === false)
6464
{
6565
$this->_minify();
6666
}

src/Resources/CssResource.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
class CssResource extends AbstractDispatchableResource
55
{
66
protected $_options = [
7-
'minify' => 'true',
7+
'minify' => true,
8+
'dispatch' => true,
89
];
910

1011
public function getExtension()

tests/ResourceManagerTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,19 @@ public function testGetFilePath()
119119
);
120120
}
121121

122+
public function testGetFileHash()
123+
{
124+
Dispatch::bind(new Dispatch(Path::system(__DIR__, '_root')));
125+
//Test cache code (apcu)
126+
for($i = 0; $i < 3; $i++)
127+
{
128+
$this->assertEquals(
129+
"7c20a3fa",
130+
ResourceManager::resources()->getFileHash(Path::system(__DIR__, '_root', 'public', 'placeholder.html'))
131+
);
132+
}
133+
}
134+
122135
public function testRequireInlineCss()
123136
{
124137
Dispatch::bind(new Dispatch(Path::system(__DIR__, '_root')));

0 commit comments

Comments
 (0)