本文整理汇总了PHP中ErrorPage::hasStaticPage方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorPage::hasStaticPage方法的具体用法?PHP ErrorPage::hasStaticPage怎么用?PHP ErrorPage::hasStaticPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorPage
的用法示例。
在下文中一共展示了ErrorPage::hasStaticPage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: requireDefaultRecords
/**
* Ensures that there is always a 404 page by checking if there's an
* instance of ErrorPage with a 404 and 500 error code. If there is not,
* one is created when the DB is built.
*/
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
if ($this->class === 'ErrorPage' && SiteTree::config()->create_default_pages) {
$defaultPages = $this->getDefaultRecords();
foreach ($defaultPages as $defaultData) {
$code = $defaultData['ErrorCode'];
$page = ErrorPage::get()->filter('ErrorCode', $code)->first();
$pageExists = !empty($page);
if (!$pageExists) {
$page = new ErrorPage($defaultData);
$page->write();
$page->publish('Stage', 'Live');
}
// Check if static files are enabled
if (!self::config()->enable_static_file) {
continue;
}
// Ensure this page has cached error content
$success = true;
if (!$page->hasStaticPage()) {
// Update static content
$success = $page->writeStaticPage();
} elseif ($pageExists) {
// If page exists and already has content, no alteration_message is displayed
continue;
}
if ($success) {
DB::alteration_message(sprintf('%s error page created', $code), 'created');
} else {
DB::alteration_message(sprintf('%s error page could not be created. Please check permissions', $code), 'error');
}
}
}
}