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'];

        $page = UtilityPage::get()->filter('ErrorCode', $code)->first();
        $pageExists = !empty($page);
        if (!$pageExists) {

            $page = UtilityPage::get()->first();
		    $pageExists = ($page && $page->exists());

            //Only create a UtilityPage on dev/build if one does not already exist.

				$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
				));
				$page->write();
                $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);

        }

        // Ensure a static error page is created from latest Utility Page content

        // Check if static files are enabled
        if (!self::config()->enable_static_file) {
            return;
        }

        // 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
            return;
        }

        if ($success) {
            DB::alteration_message(
                sprintf('%s error Utility Page created', $code),
                'created'
            );
        } else {
            DB::alteration_message(
                sprintf('%s error Utility page could not be created. Please check permissions', $code),
                'error'
            );
        }

	}
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'];

        $page = UtilityPage::get()->filter('ErrorCode', $code)->first();
        $pageExists = !empty($page);
        if (!$pageExists) {

            $page = UtilityPage::get()->first();
		    $pageExists = ($page && $page->exists());

            //Only create a UtilityPage on dev/build if one does not already exist.

				$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
				));
				$page->write();
                $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);

        }

        // Ensure a static error page is created from latest Utility Page content

        // Check if static files are enabled
        if (!self::config()->enable_static_file) {
            return;
        }

        // 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
            return;
        }

        if ($success) {
            DB::alteration_message(
                sprintf('%s error Utility Page created', $code),
                'created'
            );
        } else {
            DB::alteration_message(
                sprintf('%s error Utility page could not be created. Please check permissions', $code),
                'error'
            );
        }

	}
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' ] ; $ page = UtilityPage :: get ( ) -> filter ( 'ErrorCode' , $ code ) -> first ( ) ; $ pageExists = ! empty ( $ page ) ; if ( ! $ pageExists ) { $ page = UtilityPage :: get ( ) -> first ( ) ; $ pageExists = ( $ page && $ page -> exists ( ) ) ; //Only create a UtilityPage on dev/build if one does not already exist. $ 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 ) ) ; $ page -> write ( ) ; $ page -> copyVersionToStage ( Versioned :: DRAFT , Versioned :: LIVE ) ; } // Ensure a static error page is created from latest Utility Page content // Check if static files are enabled if ( ! self :: config ( ) -> enable_static_file ) { return ; } // 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 return ; } if ( $ success ) { DB :: alteration_message ( sprintf ( '%s error Utility Page created' , $ code ) , 'created' ) ; } else { DB :: alteration_message ( sprintf ( '%s error Utility page could not be created. Please check permissions' , $ code ) , 'error' ) ; } }
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.
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 .