src/Model/Site.php
public function requireDefaultRecords() {
		parent::requireDefaultRecords();

		if(Site::get()->count() > 0) {
			return;
		}

		$site = Site::create();
		$site->Title = _t('Multisites.DEFAULTSITE', 'Default Site');
		$site->IsDefault = true;
		$site->FolderID = Folder::find_or_make('default-site')->ID;
		$site->write();
		$site->publish('Stage', 'Live');

		DB::alteration_message('Default site created', 'created');

		$pages = SiteTree::get()->exclude('ID', $site->ID)->filter('ParentID', 0);
		$count = count($pages);
		if ($count > 0) {
			foreach($pages as $page) {
				$page->ParentID = $site->ID;
				$page->write();
				if ($page->isPublished()) {
					$page->publish('Stage', 'Live');
				}
			}

			DB::alteration_message("Moved $count existing pages under new default site.", 'changed');
		}
	}
public function requireDefaultRecords() {
		parent::requireDefaultRecords();

		if(Site::get()->count() > 0) {
			return;
		}

		$site = Site::create();
		$site->Title = _t('Multisites.DEFAULTSITE', 'Default Site');
		$site->IsDefault = true;
		$site->FolderID = Folder::find_or_make('default-site')->ID;
		$site->write();
		$site->publish('Stage', 'Live');

		DB::alteration_message('Default site created', 'created');

		$pages = SiteTree::get()->exclude('ID', $site->ID)->filter('ParentID', 0);
		$count = count($pages);
		if ($count > 0) {
			foreach($pages as $page) {
				$page->ParentID = $site->ID;
				$page->write();
				if ($page->isPublished()) {
					$page->publish('Stage', 'Live');
				}
			}

			DB::alteration_message("Moved $count existing pages under new default site.", 'changed');
		}
	}
public function requireDefaultRecords ( ) { parent :: requireDefaultRecords ( ) ; if ( Site :: get ( ) -> count ( ) > 0 ) { return ; } $ site = Site :: create ( ) ; $ site -> Title = _t ( 'Multisites.DEFAULTSITE' , 'Default Site' ) ; $ site -> IsDefault = true ; $ site -> FolderID = Folder :: find_or_make ( 'default-site' ) -> ID ; $ site -> write ( ) ; $ site -> publish ( 'Stage' , 'Live' ) ; DB :: alteration_message ( 'Default site created' , 'created' ) ; $ pages = SiteTree :: get ( ) -> exclude ( 'ID' , $ site -> ID ) -> filter ( 'ParentID' , 0 ) ; $ count = count ( $ pages ) ; if ( $ count > 0 ) { foreach ( $ pages as $ page ) { $ page -> ParentID = $ site -> ID ; $ page -> write ( ) ; if ( $ page -> isPublished ( ) ) { $ page -> publish ( 'Stage' , 'Live' ) ; } } DB :: alteration_message ( "Moved $count existing pages under new default site." , 'changed' ) ; } }
Make sure there is a site record.
Make sure there is a site record .