本文整理汇总了PHP中Bolt\Library::loadSerialize方法的典型用法代码示例。如果您正苦于以下问题:PHP Library::loadSerialize方法的具体用法?PHP Library::loadSerialize怎么用?PHP Library::loadSerialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bolt\Library
的用法示例。
在下文中一共展示了Library::loadSerialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBadLoadSerializeFails
public function testBadLoadSerializeFails()
{
$file = PHPUNIT_ROOT . '/resources/data.php';
$data = "\n\n" . 'string';
file_put_contents($file, $data);
$data = Library::loadSerialize($file);
$this->assertFalse($data);
unlink($file);
}
示例2: loadCache
/**
* Attempt to load cached configuration files.
*
* @return boolean
*/
protected function loadCache()
{
$dir = $this->app['resources']->getPath('config');
/* Get the timestamps for the config files. config_local defaults to '0', because if it isn't present,
it shouldn't trigger an update for the cache, while the others should.
*/
$timestamps = [file_exists($dir . '/config.yml') ? filemtime($dir . '/config.yml') : 10000000000, file_exists($dir . '/taxonomy.yml') ? filemtime($dir . '/taxonomy.yml') : 10000000000, file_exists($dir . '/contenttypes.yml') ? filemtime($dir . '/contenttypes.yml') : 10000000000, file_exists($dir . '/menu.yml') ? filemtime($dir . '/menu.yml') : 10000000000, file_exists($dir . '/routing.yml') ? filemtime($dir . '/routing.yml') : 10000000000, file_exists($dir . '/permissions.yml') ? filemtime($dir . '/permissions.yml') : 10000000000, file_exists($dir . '/config_local.yml') ? filemtime($dir . '/config_local.yml') : 0];
if (file_exists($this->app['resources']->getPath('cache/config_cache.php'))) {
$this->cachetimestamp = filemtime($this->app['resources']->getPath('cache/config_cache.php'));
} else {
$this->cachetimestamp = 0;
}
if ($this->cachetimestamp > max($timestamps)) {
$this->data = Lib::loadSerialize($this->app['resources']->getPath('cache/config_cache.php'));
// Check if we loaded actual data.
if (count($this->data) < 4 || empty($this->data['general'])) {
return false;
}
// Check to make sure the version is still the same. If not, effectively invalidate the
// cached config to force a reload.
if (!isset($this->data['version']) || $this->data['version'] != $this->app['bolt_long_version']) {
// The logger and the flashbags aren't available yet, so we set a flag to notify the user later.
$this->notify_update = true;
return false;
}
// Trigger the config loaded event on the resource manager
$this->app['resources']->initializeConfig($this->data);
// Yup, all seems to be right.
return true;
}
return false;
}