protected function installLegacyDatabaseFile(AttributeType $type) { $r = $this->environment->getRecord(DIRNAME_ATTRIBUTES . DIRECTORY_SEPARATOR . $type->getAttributeTypeHandle() . DIRECTORY_SEPARATOR . FILENAME_ATTRIBUTE_DB, $type->getPackageHandle()); if ($r->exists()) { \Concrete\Core\Package\Package::installDB($r->file); } }
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 upgrade() { Package::installDB($this->getPackagePath() . '/' . FILENAME_PACKAGE_DB); // now we refresh all blocks $items = $this->getPackageItems(); if (is_array($items['block_types'])) { foreach ($items['block_types'] as $item) { $item->refresh(); } } }
/** * Installs the packages database through doctrine entities and db.xml * database definitions. * * @return void */ public function installDatabase() { $this->installEntitiesDatabase(); Package::installDB($this->getPackagePath() . '/' . FILENAME_PACKAGE_DB); }
public function install_database() { $db = Loader::db(); $installDirectory = DIR_BASE_CORE . '/config'; try { Package::installDB($installDirectory . '/db.xml'); $this->indexAdditionalDatabaseFields(); } catch (Exception $e) { throw new Exception(t('Unable to install database: %s', $db->ErrorMsg())); } }
/** * Installs the packages database either through entities or if no entities * are available for the package, through the legacy db.xml if it is * available. * * @return void */ public function installDatabase() { $dbm = $this->getDatabaseStructureManager(); if ($dbm->hasEntities()) { $dbm->generateProxyClasses(); $dbm->dropObsoleteDatabaseTables(camelcase($this->getPackageHandle())); $dbm->installDatabase(); } if (file_exists($this->getPackagePath() . '/' . FILENAME_PACKAGE_DB)) { // Legacy db.xml Package::installDB($this->getPackagePath() . '/' . FILENAME_PACKAGE_DB); } }
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())); } }