当前位置: 首页>>代码示例>>PHP>>正文


PHP ErrorPage::requireDefaultRecords方法代码示例

本文整理汇总了PHP中ErrorPage::requireDefaultRecords方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorPage::requireDefaultRecords方法的具体用法?PHP ErrorPage::requireDefaultRecords怎么用?PHP ErrorPage::requireDefaultRecords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ErrorPage的用法示例。


在下文中一共展示了ErrorPage::requireDefaultRecords方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: requireDefaultRecords

 /**
  * Create default Utility Page setup
  * Ensures that there is always a 503 Utility page by checking if there's an
  * instance of ErrorPage with a 503 error code. If there is not,
  * one is created when the DB is built.
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     // Skip creation of default records
     if (!self::config()->create_default_pages) {
         return;
     }
     //Only create a UtilityPage on dev/build if one does not already exist.
     if (!UtilityPage::get()->exists()) {
         $page = UtilityPage::create(array('Title' => _t('MaintenanceMode.TITLE', 'Undergoing Scheduled Maintenance'), 'URLSegment' => _t('MaintenanceMode.URLSEGMENT', 'offline'), 'MenuTitle' => _t('MaintenanceMode.MENUTITLE', 'Utility Page'), 'Content' => _t('MaintenanceMode.CONTENT', '<h1>We&rsquo;ll be back soon!</h1>' . '<p>Sorry for the inconvenience but ' . 'our site is currently down for scheduled maintenance. ' . 'If you need to you can always <a href="mailto:#">contact us</a>, ' . 'otherwise we&rsquo;ll be back online shortly!</p>' . '<p>&mdash; The Team</p>'), 'ParentID' => 0, 'Status' => 'Published'));
         $page->write();
         $page->publish('Stage', 'Live');
         DB::alteration_message('Utility Page created', 'created');
     }
 }
开发者ID:patricknelson,项目名称:silverstripe-maintenance-mode,代码行数:21,代码来源:UtilityPage.php

示例2: requireDefaultRecords

 /**
  * Create default Utility Page setup
  * Ensures that there is always a 503 Utility page by checking if there's an
  * instance of ErrorPage with a 503 error code. If there is not,
  * one is created when the DB is built.
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     // Skip creation of default records
     if (!self::config()->create_default_pages) {
         return;
     }
     // Ensure that an assets path exists before we do any error page creation
     if (!file_exists(ASSETS_PATH)) {
         mkdir(ASSETS_PATH);
     }
     $code = self::$defaults['ErrorCode'];
     $pagePath = self::get_filepath_for_errorcode($code);
     $page = UtilityPage::get()->first();
     $pageExists = $page && $page->exists();
     //Only create a UtilityPage on dev/build if one does not already exist.
     if (!$pageExists || !file_exists($pagePath)) {
         if (!$pageExists) {
             $page = UtilityPage::create(array('Title' => _t('MaintenanceMode.TITLE', 'Undergoing Scheduled Maintenance'), 'URLSegment' => _t('MaintenanceMode.URLSEGMENT', 'offline'), 'MenuTitle' => _t('MaintenanceMode.MENUTITLE', 'Utility Page'), 'Content' => _t('MaintenanceMode.CONTENT', '<h1>We&rsquo;ll be back soon!</h1>' . '<p>Sorry for the inconvenience but ' . 'our site is currently down for scheduled maintenance. ' . 'If you need to you can always <a href="mailto:#">contact us</a>, ' . 'otherwise we&rsquo;ll be back online shortly!</p>' . '<p>&mdash; The Team</p>'), 'ParentID' => 0, 'Status' => 'Published'));
             $page->write();
             $page->publish('Stage', 'Live');
         }
         // Ensure a static error page is created from latest Utility Page content
         $response = Director::test(Director::makeRelative($page->Link()));
         $written = null;
         if ($fh = fopen($pagePath, 'w')) {
             $written = fwrite($fh, $response->getBody());
             fclose($fh);
         }
         if ($written) {
             DB::alteration_message(sprintf('%s error Utility Page created', $code), 'created');
         } else {
             DB::alteration_message(sprintf('%s error Utility page could not be created at %s. Please check permissions', $code, $pagePath), 'error');
         }
     }
 }
开发者ID:thisisbd,项目名称:silverstripe-maintenance-mode,代码行数:42,代码来源:UtilityPage.php


注:本文中的ErrorPage::requireDefaultRecords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。