1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-14 01:54:11 +02:00

+ "//" filepath shortcut in Build.php

+ 'getContentFunc' option in Source.php for lazy loading content only when needed (e.g. from DB)
This commit is contained in:
Steve Clay
2008-03-29 03:09:41 +00:00
parent d38f3d0219
commit d6c933e80d
2 changed files with 19 additions and 6 deletions

View File

@@ -54,7 +54,11 @@ class Minify_Source {
$this->lastModified = filemtime($spec['filepath']);
} elseif (isset($spec['id'])) {
$this->_id = 'id::' . $spec['id'];
$this->_content = $spec['content'];
if (isset($spec['content'])) {
$this->_content = $spec['content'];
} else {
$this->_getContentFunc = $spec['getContentFunc'];
}
$this->lastModified = isset($spec['lastModified'])
? $spec['lastModified']
: time();
@@ -74,9 +78,12 @@ class Minify_Source {
*/
public function getContent()
{
return (null !== $this->_content)
? $this->_content
: file_get_contents($this->_filepath);
return (null !== $this->_filepath)
? file_get_contents($this->_filepath)
: ((null !== $this->_content)
? $this->_content
: call_user_func($this->_getContentFunc, $this->_id)
);
}
/**
@@ -143,6 +150,7 @@ class Minify_Source {
}
protected $_content = null;
protected $_getContentFunc = null;
protected $_filepath = null;
protected $_id = null;
}