Esempio n. 1
0
 /**
  * Import a new site
  * @package 2.0
  *
  * ## OPTIONS
  *
  * [--url=<url>]
  * : URL of archive to import
  *
  * [--name=<name>]
  * : (deprecated) use --site instead
  *
  * [--site=<site>]
  * : Name of the site to create (machine-readable)
  *
  * [--label=<label>]
  * : Label for the site
  *
  * [--org=<id>]
  * : UUID of organization into which to add this site
  *
  * @subcommand import
  */
 public function import($args, $assoc_args)
 {
     $options = Sites_Command::getSiteCreateOptions($assoc_args);
     $url = Input::string($assoc_args, 'url', 'URL of archive to import');
     if (!$url) {
         $this->logger->error('Please enter a URL.');
     }
     try {
         //If the site does not yet exist, it will throw an error.
         $site = $this->sites->get($options['name']);
         $this->logger->error(sprintf('A site named %s already exists.', $options['name']));
         exit;
     } catch (\Exception $e) {
         //Creating a new site
         $workflow = $this->sites->addSite($options);
         $workflow->wait();
         $this->workflowOutput($workflow);
         //Add site to SitesCache
         $final_task = $workflow->get('final_task');
         $site = $this->sites->addSiteToCache($final_task->site_id);
         sleep(10);
         //Avoid false site-DNE errors
     }
     $workflow = $site->import($url);
     $workflow->wait();
     $this->workflowOutput($workflow);
 }
Esempio n. 2
0
 /**
  * Import a new site
  * @package 2.0
  *
  * ## OPTIONS
  *
  * [--url=<url>]
  * : URL of archive to import
  *
  * [--name=<name>]
  * : (deprecated) use --site instead
  *
  * [--site=<site>]
  * : Name of the site to create (machine-readable)
  *
  * [--label=<label>]
  * : Label for the site
  *
  * [--org=<id>]
  * : UUID of organization into which to add this site
  *
  * @subcommand import
  */
 public function import($args, $assoc_args)
 {
     $options = Sites_Command::getSiteCreateOptions($assoc_args);
     $url = Input::string($assoc_args, 'url', "URL of archive to import");
     if (!$url) {
         throw new TerminusException("Please enter a URL.");
     }
     $workflow = $this->sites->addSite($options);
     $workflow->wait();
     $this->workflowOutput($workflow);
     // Add Site to SitesCache
     $final_task = $workflow->get('final_task');
     $this->sites->addSiteToCache($final_task->site_id);
     sleep(10);
     //To stop erroneous site-DNE errors
     Terminus::launch_self('site', array('import'), array('url' => $assoc_args['url'], 'site' => $options['name'], 'element' => 'all'));
 }