protected function create() { $action = ProjectAction::newFromContext($this->getContext()); $id = $this->getOption('id'); $displayTitle = $this->getOption('display-title'); $password = $this->getOption('password'); $siteUrl = $this->getOption('site-url'); if (!$id || !$displayTitle) { $this->error('--id and --display-title are required.'); } if (!$password) { $inputConfirm = null; $this->out('Enter password for this project (leave blank to abort):'); while (($input = $this->cliInputSecret()) !== '' && $input !== $inputConfirm) { if (!is_string($inputConfirm)) { $inputConfirm = $input; $this->out('Re-enter password to confirm:'); } else { $inputConfirm = null; $this->out('Passwords don\'t match, please try again:'); } } if ($input === '') { $this->error('Password is required.'); } $password = $input; } $data = $action->create($id, array('password' => $password, 'displayTitle' => $displayTitle, 'siteUrl' => $siteUrl)); $error = $action->getError(); if ($error) { $this->error($error['info']); } $this->out('Project ' . $displayTitle . ' has been succesfully created!' . PHP_EOL . 'The following auth token has been generated for this project:' . PHP_EOL . PHP_EOL . "\t" . $data['authToken'] . PHP_EOL . PHP_EOL . 'You will need it to perform actions that require authentication.' . PHP_EOL . 'If you ever loose it, you can generate a new token with the refreshProjectToken.php script.'); }
public function execute() { $action = ProjectAction::newFromContext($this->getContext()); $action->doAction(); $this->setAction($action); $this->content = $this->initContent(); }