/**
  * Override parent method
  * @note: we're removing generating of doctrine proxy classes within the try {} method
  * below (see parent for whats removed); generation is done in the after_exec hook of
  * pagodabox install while directories are still writable
  */
 public function install_database()
 {
     // Already configured? Bail out...
     $db = Loader::db();
     if (count($db->GetCol("SHOW TABLES")) > 0) {
         fwrite(STDERR, "\nDatabase already installed; leaving existing installation untouched and moving on...\n\n");
         exit(0);
     }
     try {
         Package::installDB(DIR_BASE_CORE . '/config/db.xml');
         $this->indexAdditionalDatabaseFields();
         $configuration = new Configuration();
         $version = $configuration->getVersion(Config::get('concrete.version_db'));
         $version->markMigrated();
     } catch (\Exception $e) {
         fwrite(STDERR, "\nUnable to install database: " . $db->ErrorMsg() . "\n\n");
         exit(0);
     }
 }
 public function install_database()
 {
     $db = Database::get();
     $num = $db->GetCol("show tables");
     if (count($num) > 0) {
         throw new \Exception(t('There are already %s tables in this database. concrete5 must be installed in an empty database.', count($num)));
     }
     $installDirectory = DIR_BASE_CORE . '/config';
     try {
         $em = \ORM::entityManager('core');
         $dbm = Core::make('database/structure', $em);
         $dbm->generateProxyClasses();
         Package::installDB($installDirectory . '/db.xml');
         $this->indexAdditionalDatabaseFields();
         $configuration = new Configuration();
         $version = $configuration->getVersion(Config::get('concrete.version_db'));
         $version->markMigrated();
     } catch (\Exception $e) {
         throw new \Exception(t('Unable to install database: %s', $db->ErrorMsg() ? $db->ErrorMsg() : $e->getMessage()));
     }
 }
 public function install_database()
 {
     $db = Database::get();
     $num = $db->GetCol("show tables");
     if (count($num) > 0) {
         throw new \Exception(t('There are already %s tables in this database. concrete5 must be installed in an empty database.', count($num)));
     }
     $installDirectory = DIR_BASE_CORE . '/config';
     try {
         // Retrieving metadata from the entityManager created with \ORM::entityManager()
         // will result in a empty metadata array. Because all drivers are wrapped in a driverChain
         // the method getAllMetadata() of Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory
         // is going to return a empty array. To overcome this issue a new EntityManager is create with the
         // only purpose to be used during the installation.
         $config = Setup::createConfiguration(true, \Config::get('database.proxy_classes'));
         \Doctrine\Common\Annotations\AnnotationReader::addGlobalIgnoredName('subpackages');
         \Doctrine\Common\Annotations\AnnotationReader::addGlobalIgnoredName('package');
         // Use default AnnotationReader
         $driverImpl = $config->newDefaultAnnotationDriver(DIR_BASE_CORE . DIRECTORY_SEPARATOR . DIRNAME_CLASSES . DIRECTORY_SEPARATOR . DIRNAME_ENTITIES, false);
         $config->setMetadataDriverImpl($driverImpl);
         $em = EntityManager::create(\Database::connection(), $config);
         $dbm = new DatabaseStructureManager($em);
         $dbm->destroyProxyClasses();
         $dbm->generateProxyClasses();
         Package::installDB($installDirectory . '/db.xml');
         $dbm->installDatabase();
         $this->indexAdditionalDatabaseFields();
         $configuration = new Configuration();
         $version = $configuration->getVersion(Config::get('concrete.version_db'));
         $version->markMigrated();
         $configuration->registerPreviousMigratedVersions();
     } catch (\Exception $e) {
         throw new \Exception(t('Unable to install database: %s', $db->ErrorMsg() ? $db->ErrorMsg() : $e->getMessage()));
     }
 }