Source for file Serializer.php
Documentation is available at Serializer.php
public function add($def, $config) {
if (!$this->_prepareDir($config)) return false;
return $this->_write($file, serialize($def));
public function set($def, $config) {
if (!$this->_prepareDir($config)) return false;
return $this->_write($file, serialize($def));
public function replace($def, $config) {
if (!$this->_prepareDir($config)) return false;
return $this->_write($file, serialize($def));
public function get($config) {
public function remove($config) {
public function flush($config) {
if (!$this->_prepareDir($config)) return false;
while (false !==
($filename =
readdir($dh))) {
if (empty($filename)) continue;
if ($filename[0] ===
'.') continue;
unlink($dir .
'/' .
$filename);
if (!$this->_prepareDir($config)) return false;
while (false !==
($filename =
readdir($dh))) {
if (empty($filename)) continue;
if ($filename[0] ===
'.') continue;
if ($this->isOld($key, $config)) unlink($dir .
'/' .
$filename);
* Generates the file path to the serial file corresponding to
* the configuration and definition name
* Generates the path to the directory contain this cache's serial files
* @note No trailing slash
return $base .
'/' .
$this->type;
* Generates path to base directory that contains all definition type
$base =
$config->get('Cache', 'SerializerPath');
* Convenience wrapper function for file_put_contents
* @param $file File name to write to
* @param $data Data to write into file
* @return Number of bytes written if success, or false if failure.
private function _write($file, $data) {
* Prepares the directory that this type stores the serials in
* @return True if successful
private function _prepareDir($config) {
please create or change using %Cache.SerializerPath',
} elseif (!$this->_testPermissions($base)) {
$old =
umask(0022); // disable group and world writes
} elseif (!$this->_testPermissions($directory)) {
* Tests permissions on a directory and throws out friendly
* error messages and attempts to chmod it itself if possible
private function _testPermissions($dir) {
// early abort, if it is writable, everything is hunky-dory
// generally, you'll want to handle this beforehand
// so a more specific error message can be given
// POSIX system, we can give more specific advice
// we can chmod it ourselves
} elseif (filegroup($dir) ===
posix_getgid()) {
// PHP's probably running as nobody, so we'll
// need to give global permissions
'please chmod to ' .
$chmod,
'please alter file permissions',
Documentation generated on Thu, 19 Jun 2008 18:50:19 -0400 by phpDocumentor 1.4.2