Ejemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->instances->lock();
     $container = $this->getContainer();
     $mysql_type = $container->getParameter('mysql_type');
     if ($mysql_type == "") {
         $this->doCommand($output, OutputInterface::VERBOSITY_NORMAL, 'config', array());
         $this->getApplication()->loadContainer();
         $this->instances = $this->getContainer()->get('instances');
     }
     $instance = $this->instances->find(Instance::makeId($input->getOption('root'), $input->getOption('name')));
     if ($instance === NULL) {
         $instance = new Instance();
         $instance->setRoot($input->getOption('root'));
         $instance->setName($input->getOption('name'));
     } elseif (!$input->getOption('force')) {
         throw new \Exception("Cannot create instance. Use -f to overwrite existing instance.");
     }
     if ($input->getOption('url')) {
         $instance->setUrl($input->getOption('url'));
     }
     $this->instances->create($instance, !$input->getOption('skip-url'), !$input->getOption('skip-db'), $input->getOption('perm'));
     $this->instances->save();
     if ($output->getVerbosity() > OutputInterface::VERBOSITY_QUIET) {
         $this->export($instance->getRoot(), $instance->getName(), $input->getOption('prefix'), $input->getOption('output-file'), $output);
     }
 }
Ejemplo n.º 2
0
 /**
  * Create a new instance (with given web-root, URL,
  * and DB credentials -- if given). If an existing one
  * exists, it will be overwritten.
  *
  * @param Instance $instance
  * @param bool $useWeb
  * @param bool $useDB
  * @param string $perm PERM_SUPER, PERM_ADMIN
  */
 public function create($instance, $useWeb = TRUE, $useDB = TRUE, $perm = DatabaseManagementInterface::PERM_ADMIN)
 {
     if ($useDB) {
         if (!$instance->getDatasource()) {
             $instance->setDatasource($this->db->createDatasource(basename($instance->getRoot()) . $instance->getName()));
         }
         $this->db->dropDatabase($instance->getDatasource());
         $this->db->createDatabase($instance->getDatasource(), $perm);
     }
     if ($useWeb) {
         if (!$instance->getUrl()) {
             $instance->setUrl('http://localhost:7979');
         }
         $this->httpd->dropVhost($instance->getRoot(), $instance->getUrl());
         $this->httpd->createVhost($instance->getRoot(), $instance->getUrl());
     }
     $this->put($instance->getId(), $instance);
 }