public function build($request)
 {
     //Only build the classes do not populate the records
     $_REQUEST['dont_populate'] = 1;
     $renderer = DebugView::create();
     $renderer->writeHeader();
     $renderer->writeInfo("Orient Environment Builder: Do not run while logged in as a member", Director::absoluteBaseURL());
     echo "<div class=\"build\">";
     $da = DatabaseAdmin::create();
     return $da->handleRequest($request, $this->model);
     echo "</div>";
     $renderer->writeFooter();
 }
Exemplo n.º 2
0
 public function fire()
 {
     // make sure we have a fresh manifest
     $this->call('clear:cache');
     /** @var DatabaseAdmin $da */
     $da = DatabaseAdmin::create();
     // hack untill we have something better...
     ob_start();
     $da->doBuild();
     $content = ob_get_contents();
     ob_get_clean();
     foreach (explode("\n", $content) as $line) {
         $this->displayBuildMessage($line);
     }
 }
 public function build($request)
 {
     if (Director::is_cli()) {
         $da = DatabaseAdmin::create();
         return $da->handleRequest($request, $this->model);
     } else {
         $renderer = DebugView::create();
         $renderer->writeHeader();
         $renderer->writeInfo("Environment Builder", Director::absoluteBaseURL());
         echo "<div class=\"build\">";
         $da = DatabaseAdmin::create();
         return $da->handleRequest($request, $this->model);
         echo "</div>";
         $renderer->writeFooter();
     }
 }
Exemplo n.º 4
0
 /**
  * Build the default data, calling requireDefaultRecords on all
  * DataObject classes
  * Should match the $url_handlers rule:
  *		'build/defaults' => 'buildDefaults',
  */
 function buildDefaults()
 {
     $da = DatabaseAdmin::create();
     if (!Director::is_cli()) {
         $renderer = DebugView::create();
         $renderer->writeHeader();
         $renderer->writeInfo("Defaults Builder", Director::absoluteBaseURL());
         echo "<div style=\"margin: 0 2em\">";
     }
     $da->buildDefaults();
     if (!Director::is_cli()) {
         echo "</div>";
         $renderer->writeFooter();
     }
 }
Exemplo n.º 5
0
 /**
  * Rebuilds the database programmatically and keeps track of new tables and fields
  *
  * @return array
  */
 public static function rebuild_database()
 {
     SS_ClassLoader::instance()->getManifest()->regenerate();
     ob_start();
     $da = DatabaseAdmin::create();
     $da->handleRequest(new SS_HTTPRequest("POST", "build", array('flush' => 'all')), DataModel::inst());
     $output = ob_get_contents();
     ob_end_clean();
     $database_result = array();
     foreach (explode("\n", $output) as $line) {
         if (preg_match('/Table ([A-Za-z0-9_:]+) created/', $line, $matches)) {
             $table_name = str_replace(":", "", $matches[1]);
             if (substr($table_name, -9) == "_versions" || substr($table_name, -5) == "_Live") {
                 continue;
             }
             $database_result[$table_name] = array('created' => true, 'fields' => array());
         } elseif (preg_match('/Field (.*) created as ([A-Za-z0-9_\\(\\)\\"\',]+)/', $line, $matches)) {
             list($table_name, $field_name) = explode(".", $matches[1]);
             if (substr($table_name, -9) == "_versions" || substr($table_name, -5) == "_Live") {
                 continue;
             }
             $field_name = str_replace(":", "", $field_name);
             $field_type = $matches[2];
             if (!isset($database_result[$table_name])) {
                 $database_result[$table_name] = array('created' => false, 'fields' => array());
             }
             $database_result[$table_name]['fields'][] = "{$field_name} ({$field_type})";
         }
     }
     return $database_result;
 }
 public function run($request)
 {
     $dbAdmin = DatabaseAdmin::create();
     increase_time_limit_to(600);
     SS_ClassLoader::instance()->getManifest()->regenerate();
     $dbAdmin->clearAllData();
     $dbAdmin->doBuild(true);
     // Build again for good measure
     $dbAdmin->doBuild(true, false);
     //Move images to assets/Uploads/
     $assetsDir = Director::baseFolder() . '/assets/Uploads';
     $imagesDir = Director::baseFolder() . '/swipestripe-builder/images';
     foreach (new DirectoryIterator($assetsDir) as $fileInfo) {
         if (!$fileInfo->isDot()) {
             @unlink($fileInfo->getPathname());
         }
     }
     Filesystem::sync();
     foreach (new DirectoryIterator($imagesDir) as $fileInfo) {
         if ($fileInfo->isFile()) {
             copy($fileInfo->getPathname(), $assetsDir . '/' . $fileInfo->getFilename());
         }
     }
     //Build DB
     $fixture = Injector::inst()->create('YamlFixture', self::$fixture_file);
     $fixture->writeInto($this->getFixtureFactory());
     //Update the shop config
     $config = ShopConfig::current_shop_config();
     $config->BaseCurrency = 'NZD';
     $config->BaseCurrencySymbol = '$';
     $config->EmailSignature = '';
     $config->ReceiptSubject = 'Your order details from SwipeStripe demo site';
     $config->ReceiptBody = '';
     $config->ReceiptFrom = '*****@*****.**';
     $config->NotificationSubject = 'New order on SwipeStripe demo site';
     $config->NotificationBody = '';
     $config->NotificationTo = '*****@*****.**';
     $config->write();
     // Populate flat fee shipping rates
     $this->createShippingRates();
     // Populate tax rates
     $this->createTaxRates();
     // Populate exchange rates
     $this->createExchangeRates();
     // Populate coupon codes
     $this->createCouponCodes();
     // Product categories
     $this->createProductCategories();
     // Product images
     $this->createProductImages();
     // Clear product meta
     $products = Product::get();
     if ($products && $products->exists()) {
         foreach ($products as $product) {
             $product->ExtraMeta = '';
             $product->doPublish();
         }
     }
     // Create home page
     if (class_exists('HomePage')) {
         $page = Page::get()->where("\"URLSegment\" = 'home'")->first();
         $page->ClassName = 'HomePage';
         $page->doPublish();
     }
 }