|
Perforce Chronicle 2012.2/486814
API Documentation
|
A slight extension to Zend's File backend to add support for our 'namespace' option. More...
Public Member Functions | |
| __construct (array $options=array()) | |
| Extend parent to add the 'namespace' option. | |
| setOption ($name, $value) | |
| Extends parent to work the 'namespace' option into the existing 'file_name_prefix' option. | |
A slight extension to Zend's File backend to add support for our 'namespace' option.
We implemented namespace support by mapping the 'namespace' option over to the existing 'file_name_prefix'.
| P4Cms_Cache_Backend_File::__construct | ( | array $ | options = array() | ) |
Extend parent to add the 'namespace' option.
| array | $options | associative array of options |
{
$this->_options['namespace'] = false;
return parent::__construct($options);
}
| P4Cms_Cache_Backend_File::setOption | ( | $ | name, |
| $ | value | ||
| ) |
Extends parent to work the 'namespace' option into the existing 'file_name_prefix' option.
| string | $name | the option name |
| mixed | $value | the options value |
{
// if we aren't touching a related setting let parent handle it
if ($name != 'namespace' && $name != 'file_name_prefix') {
parent::setOption($name, $value);
return;
}
// pull out references to the namespace and file_name_prefix
// then calculate our current namespaced based suffix.
$namespace =& $this->_options['namespace'];
$prefix =& $this->_options['file_name_prefix'];
$suffix = $namespace ? ('_' . md5($namespace)) : '';
// strip the current namespace based suffix from the file
// name prefix if its present
if (substr($prefix, strlen($suffix) * -1) == $suffix) {
$prefix = substr($prefix, 0, strlen($prefix) - strlen($suffix));
}
// let parent update the namespace/file_name_prefix
parent::setOption($name, $value);
// namespace may have changed; re-calculate suffix and
// tack it onto our file_name_prefix
$suffix = $namespace ? ('_' . md5($namespace)) : '';
$this->_options['file_name_prefix'] = $prefix . $suffix;
}