public function run($request)
 {
     $masterPage = false;
     // Group all pages under a page
     $masterPages = Page::get()->filter('Title', 'flowchart-holder');
     if ($masterPages->count()) {
         $masterPage = $masterPages->first();
     }
     if (!$masterPage) {
         $masterPage = new Page();
         $masterPage->Title = 'flowchart-holder';
         $masterPage->write();
     }
     $numPages = 100;
     for ($a = 0; $a < $numPages; $a++) {
         $randomName = uniqid();
         $page = new FlowchartPage();
         $page->Title = 'flowchart-' . $randomName;
         $page->URLSegment = 'flowchart-' . $randomName;
         $page->ParentID = $masterPage->ID;
         $page->write();
         echo '- ' . $page->Title . PHP_EOL;
     }
 }
 /**
  * Returns the {@Link FieldList} of cms form fields for editing this object
  *
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Remove LinkedStateID in order to filter out current record ID
     $fields->removeByName('LinkedStateID');
     // Remove parentID. Re-add as TreeDropdownField where needed
     $fields->removeByName('ParentID');
     $number = $fields->dataFieldByName('Number');
     $title = $fields->dataFieldByName('TitleText');
     $content = $fields->dataFieldByName('Content');
     $number->setRightTitle("Displayed in flow state box");
     $title->setRightTitle("Displayed in flow state box");
     $content->setDescription("Extra information related to state. May be displayed on hover, or click");
     $spanOpt = array("two" => "two", "four" => "four", "six" => "six", "eight" => "eight");
     $fields->insertAfter(new DropdownField('Size', "Relative display width", $spanOpt), 'TitleText');
     $fields->insertAfter($linkedState = new DropdownField('LinkedStateID', "Linked State", FlowState::get()->exclude('ID', $this->ID)->map('ID', 'Title')), 'Content');
     $linkedState->setEmptyString(' ')->setRightTitle("HTML link to another State");
     // If not within a flowchart page re-add parentID as DropdownField
     if (Controller::curr() instanceof FlowchartAdmin) {
         $fields->insertAfter(new DropdownField('ParentID', "Belongs to", FlowchartPage::get()->map('ID', 'Title')), 'Content');
     }
     return $fields;
 }