public function perform(Installer $installer)
 {
     $this->setServiceLocator($installer->getServiceLocator());
     foreach (array_keys($this->templates) as $label) {
         $this->installTemplate($label);
     }
 }
Example #2
0
 /**
  * Install the test database schema.
  */
 public static function installSchema()
 {
     $manager = new Installer();
     $manager->setServiceLocator(self::getApplication()->getServiceManager());
     $manager->registerTask('Omeka\\Installation\\Task\\InstallSchemaTask');
     $result = $manager->install();
 }
 public function perform(Installer $installer)
 {
     $filesDir = OMEKA_PATH . '/files';
     if (!is_dir($filesDir) || !is_writable($filesDir)) {
         $installer->addError(sprintf('"%s" is not a writable directory.', $filesDir));
         return;
     }
 }
Example #4
0
 public function perform(Installer $installer)
 {
     $em = $installer->getServiceLocator()->get('Omeka\\EntityManager');
     $cache = $em->getConfiguration()->getMetadataCacheImpl();
     if (!$cache) {
         return;
     }
     $cache->deleteAll();
 }
Example #5
0
 public function perform(Installer $installer)
 {
     if (version_compare(PHP_VERSION, self::PHP_MINIMUM_VERSION, '<')) {
         $installer->addError(sprintf('The installed PHP version (%1$s) is too low. Omeka requires at least version %2$s', PHP_VERSION, self::PHP_MINIMUM_VERSION));
     }
     foreach (self::$requiredExtensions as $ext) {
         if (!extension_loaded($ext)) {
             $installer->addError(sprintf('Omeka requires the PHP extension %s, and it is not loaded.', $ext));
         }
     }
 }
Example #6
0
 public function perform(Installer $installer)
 {
     $migrator = $installer->getServiceLocator()->get('Omeka\\MigrationManager');
     $conn = $installer->getServiceLocator()->get('Omeka\\Connection');
     $migrations = $migrator->getAvailableMigrations();
     $conn->beginTransaction();
     foreach ($migrations as $version => $data) {
         $migrator->recordMigration($version);
     }
     $conn->commit();
 }
 public function perform(Installer $installer)
 {
     $vars = $installer->getVars('Omeka\\Installation\\Task\\AddDefaultSettingsTask');
     $this->defaultSettings['administrator_email'] = $vars['administrator_email'];
     $this->defaultSettings['installation_title'] = $vars['installation_title'];
     $this->defaultSettings['time_zone'] = $vars['time_zone'];
     $settings = $installer->getServiceLocator()->get('Omeka\\Settings');
     foreach ($this->defaultSettings as $id => $value) {
         $settings->set($id, $value);
     }
 }
 public function perform(Installer $installer)
 {
     $rdfImporter = $installer->getServiceLocator()->get('Omeka\\RdfImporter');
     $entityManager = $installer->getServiceLocator()->get('Omeka\\EntityManager');
     foreach ($this->vocabularies as $vocabulary) {
         $response = $rdfImporter->import($vocabulary['strategy'], $vocabulary['vocabulary'], ['file' => OMEKA_PATH . "/data/vocabularies/{$vocabulary['file']}", 'format' => $vocabulary['format']]);
         if ($response->isError()) {
             $installer->addErrorStore($response->getErrorStore());
             return;
         }
         $entityManager->clear();
     }
 }
 public function perform(Installer $installer)
 {
     try {
         $connection = $installer->getServiceLocator()->get('Omeka\\Connection');
         $connection->connect();
     } catch (\Exception $e) {
         $installer->addError($e->getMessage());
         return;
     }
     $version = $connection->getWrappedConnection()->getServerVersion();
     if (version_compare($version, self::MYSQL_MINIMUM_VERSION, '<')) {
         $installer->addError(sprintf('Omeka requires at least MySQL version %s, but this server is running version %s.', self::MYSQL_MINIMUM_VERSION, $version));
     }
 }
Example #10
0
 public function perform(Installer $installer)
 {
     $apiManager = $installer->getServiceLocator()->get('Omeka\\ApiManager');
     $entityManager = $installer->getServiceLocator()->get('Omeka\\EntityManager');
     $vars = $installer->getVars('Omeka\\Installation\\Task\\CreateFirstUserTask');
     $response = $apiManager->create('users', ['o:is_active' => true, 'o:role' => 'global_admin', 'o:name' => $vars['name'], 'o:email' => $vars['email']]);
     if ($response->isError()) {
         $installer->addErrorStore($response->getErrorStore());
         return;
     }
     // Set the password.
     $user = $response->getContent()->jsonSerialize();
     $userEntity = $entityManager->find('Omeka\\Entity\\User', $user['o:id']);
     $userEntity->setPassword($vars['password']);
     $entityManager->flush();
 }
Example #11
0
 /**
  * Create the installer service.
  * 
  * @param ServiceLocatorInterface $serviceLocator
  * @return Installer
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('Config');
     if (!isset($config['installer']['tasks'])) {
         throw new Exception\ConfigException('Missing installer configuration');
     }
     $installer = new Installer();
     foreach ($config['installer']['pre_tasks'] as $task) {
         $this->validateTask($task);
         $installer->registerPreTask($task);
     }
     foreach ($config['installer']['tasks'] as $task) {
         $this->validateTask($task);
         $installer->registerTask($task);
     }
     return $installer;
 }
Example #12
0
 public function perform(Installer $installer)
 {
     $schemaPath = OMEKA_PATH . '/data/install/schema.sql';
     if (!is_readable($schemaPath)) {
         $installer->addError('Could not read the schema installation file.');
         return;
     }
     $schema = file_get_contents($schemaPath);
     $statements = explode(';', $schema);
     $connection = $installer->getServiceLocator()->get('Omeka\\Connection');
     try {
         foreach ($statements as $statement) {
             $statement = trim($statement);
             if ('' === $statement) {
                 continue;
             }
             $connection->exec($statement);
         }
     } catch (DBALException $e) {
         $installer->addError($e->getMessage());
         return;
     }
 }
Example #13
0
 public function perform(Installer $installer)
 {
     $installer->addError('error_message');
 }