src/pages/ExtensibleSearchPage.php
public function requireDefaultRecords() {

		parent::requireDefaultRecords();
		$stage = Versioned::get_stage() ?: 'Stage';
		Versioned::set_stage('Stage');

		// Determine whether pages should be created.

		if(!self::config()->create_default_pages) {
			return;
		}

		// This is required to support multiple sites.

		if(ClassInfo::exists(Multisites::class)) {
			foreach(Site::get() as $site) {

				// The problem is that class name mapping happens after this, but we need it right now to query pages.

				if(!SiteTree::get()->filter(array(
					'ClassName' => array(
						ExtensibleSearchPage::class,
						'ExtensibleSearchPage'
					),
					'SiteID' => $site->ID
				))->first()) {

					// Instantiate an extensible search page.

					$page = ExtensibleSearchPage::create();
					$page->ParentID = $site->ID;
					$page->Title = 'Search Page';
					$page->write();
					DB::alteration_message("\"{$site->Title}\" Extensible Search Page", 'created');
				}
			}
		}
		else {

			// The problem is that class name mapping happens after this, but we need it right now to query pages.

			if(!SiteTree::get()->filter('ClassName', array(
				ExtensibleSearchPage::class,
				'ExtensibleSearchPage'
			))->first()) {

				// Instantiate an extensible search page.

				$page = ExtensibleSearchPage::create();
				$page->Title = 'Search Page';
				$page->write();
				DB::alteration_message('"Default" Extensible Search Page', 'created');
			}
		}
		Versioned::set_stage($stage);
	}
public function requireDefaultRecords() {

		parent::requireDefaultRecords();
		$stage = Versioned::get_stage() ?: 'Stage';
		Versioned::set_stage('Stage');

		// Determine whether pages should be created.

		if(!self::config()->create_default_pages) {
			return;
		}

		// This is required to support multiple sites.

		if(ClassInfo::exists(Multisites::class)) {
			foreach(Site::get() as $site) {

				// The problem is that class name mapping happens after this, but we need it right now to query pages.

				if(!SiteTree::get()->filter(array(
					'ClassName' => array(
						ExtensibleSearchPage::class,
						'ExtensibleSearchPage'
					),
					'SiteID' => $site->ID
				))->first()) {

					// Instantiate an extensible search page.

					$page = ExtensibleSearchPage::create();
					$page->ParentID = $site->ID;
					$page->Title = 'Search Page';
					$page->write();
					DB::alteration_message("\"{$site->Title}\" Extensible Search Page", 'created');
				}
			}
		}
		else {

			// The problem is that class name mapping happens after this, but we need it right now to query pages.

			if(!SiteTree::get()->filter('ClassName', array(
				ExtensibleSearchPage::class,
				'ExtensibleSearchPage'
			))->first()) {

				// Instantiate an extensible search page.

				$page = ExtensibleSearchPage::create();
				$page->Title = 'Search Page';
				$page->write();
				DB::alteration_message('"Default" Extensible Search Page', 'created');
			}
		}
		Versioned::set_stage($stage);
	}
public function requireDefaultRecords ( ) { parent :: requireDefaultRecords ( ) ; $ stage = Versioned :: get_stage ( ) ? : 'Stage' ; Versioned :: set_stage ( 'Stage' ) ; // Determine whether pages should be created. if ( ! self :: config ( ) -> create_default_pages ) { return ; } // This is required to support multiple sites. if ( ClassInfo :: exists ( Multisites :: class ) ) { foreach ( Site :: get ( ) as $ site ) { // The problem is that class name mapping happens after this, but we need it right now to query pages. if ( ! SiteTree :: get ( ) -> filter ( array ( 'ClassName' => array ( ExtensibleSearchPage :: class , 'ExtensibleSearchPage' ) , 'SiteID' => $ site -> ID ) ) -> first ( ) ) { // Instantiate an extensible search page. $ page = ExtensibleSearchPage :: create ( ) ; $ page -> ParentID = $ site -> ID ; $ page -> Title = 'Search Page' ; $ page -> write ( ) ; DB :: alteration_message ( "\"{$site->Title}\" Extensible Search Page" , 'created' ) ; } } } else { // The problem is that class name mapping happens after this, but we need it right now to query pages. if ( ! SiteTree :: get ( ) -> filter ( 'ClassName' , array ( ExtensibleSearchPage :: class , 'ExtensibleSearchPage' ) ) -> first ( ) ) { // Instantiate an extensible search page. $ page = ExtensibleSearchPage :: create ( ) ; $ page -> Title = 'Search Page' ; $ page -> write ( ) ; DB :: alteration_message ( '"Default" Extensible Search Page' , 'created' ) ; } } Versioned :: set_stage ( $ stage ) ; }
Instantiate a search page, should one not exist.
Instantiate a search page should one not exist .