本文整理汇总了PHP中FileCache::saveFile方法的典型用法代码示例。如果您正苦于以下问题:PHP FileCache::saveFile方法的具体用法?PHP FileCache::saveFile怎么用?PHP FileCache::saveFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileCache
的用法示例。
在下文中一共展示了FileCache::saveFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Rendering a layout. It also renders the views that the layout contains.
* @throws AiryException
*/
public function render()
{
//To get the layout file
$layoutContent = file_get_contents($this->_layoutPath);
$this->prepareContent($layoutContent);
//Fetch each views
$viewContents = array();
foreach ($this->_layout as $contentKey => $viewComponent) {
//check if it is an array that contains module controller action
if (is_array($viewComponent)) {
$moduleName = MvcReg::getModuleName();
$moduleName = isset($viewComponent[self::MODULE]) ? $viewComponent[self::MODULE] : $moduleName;
try {
if (isset($viewComponent[self::CONTROLLER])) {
$controllerName = $viewComponent[self::CONTROLLER];
} else {
throw new AiryException('Layout is missing controller');
}
if (isset($viewComponent[self::ACTION])) {
$actionName = $viewComponent[self::ACTION];
} else {
throw new AiryException('Layout is missing controller');
}
$paramString = "";
if (isset($viewComponent[self::PARAMS])) {
$paramString = $this->getParamString($viewComponent[self::PARAMS]);
}
$HttpServerHost = PathService::getAbsoluteHostURL();
$config = Config::getInstance();
$LeadingUrl = $HttpServerHost . "/" . $config->getLeadFileName();
$mvcKeywords = $config->getMVCKeyword();
$moduleKey = $mvcKeywords['module'];
$controllerKey = $mvcKeywords['controller'];
$actionKey = $mvcKeywords['action'];
$moduleName = RouterHelper::hyphenToCamelCase($moduleName);
$controllerName = RouterHelper::hyphenToCamelCase($controllerName, TRUE);
$actionName = RouterHelper::hyphenToCamelCase($actionName);
$actionPath = $moduleKey . "=" . $moduleName . "&" . $controllerKey . "=" . $controllerName . "&" . $actionKey . "=" . $actionName;
$url = $LeadingUrl . "?" . $actionPath . $paramString;
//check if it is already signed in
//if yes, add current action into allow action query string
if (Authentication::isLogin($moduleName)) {
$filename = "mca_file" . microtime(true);
$md5Filename = md5($filename);
$content = $moduleName . ";" . $controllerName . ";" . $actionName;
$content = md5($content);
FileCache::saveFile($md5Filename, $content);
$url = $url . '&' . self::ALLOW_THIS_ACTION . '=' . $md5Filename;
}
$viewContent = $this->getData($url);
$viewContents[$contentKey] = $viewContent;
} catch (Exception $e) {
$errorMsg = sprintf("View Exception: %s", $e->getMessage());
throw new AiryException($errorMsg);
}
} else {
if ($viewComponent instanceof AppView) {
//Use $this->_view->render();
$viewComponent->setInLayout(true);
$viewContent = $viewComponent->render();
$viewContents[$contentKey] = $viewContent;
} else {
$viewContent = file_get_contents($viewComponent);
$viewContent = Language::getInstance()->replaceWordByKey($viewContent);
$viewContents[$contentKey] = $viewContent;
}
}
}
/**
* Deal with layout variables
*/
if (!is_null($this->_variables)) {
foreach ($this->_variables as $name => $value) {
if ($value instanceof UIComponent || $value instanceof JUIComponent) {
$htmlValue = $value->render();
$newHtmlValue = Language::getInstance()->replaceWordByKey($htmlValue);
${$name} = $newHtmlValue;
} else {
${$name} = $value;
}
}
}
//Loop through each contents
//Replace view components with keywords
$layoutContent = $this->composeContent($layoutContent, $viewContents);
//Check if inserting doctype at the beginning of the view content
if (!$this->_noDoctype) {
if (is_null($this->_doctype)) {
$this->setDoctype();
}
}
$layoutContent = $this->_doctype . $layoutContent;
//Stream output
$existed = in_array("airy.layout", stream_get_wrappers());
if ($existed) {
stream_wrapper_unregister("airy.layout");
//.........这里部分代码省略.........