/** * Output a clear explanation for domains API errors. * * @param ClientException $e * @param Project $project * * @throws ClientException If it can't be explained. */ protected function handleApiException(ClientException $e, Project $project) { $response = $e->getResponse(); if ($response !== null && $response->getStatusCode() === 403) { $project->ensureFull(); $data = $project->getData(); if (!$project->hasLink('#manage-domains') && !empty($data['subscription']['plan']) && $data['subscription']['plan'] === 'development') { $this->stdErr->writeln('This project is on a Development plan. Upgrade the plan to add domains.'); } } else { throw $e; } }
/** * @param string $property * @param string $value * @param Project $project * * @return int */ protected function setProperty($property, $value, Project $project) { if (!$this->validateValue($property, $value)) { return 1; } $type = $this->getType($property); if ($type === 'boolean' && $value === 'false') { $value = false; } settype($value, $type); $currentValue = $project->getProperty($property); if ($currentValue === $value) { $this->stdErr->writeln("Property <info>{$property}</info> already set as: " . $this->formatter->format($value, $property)); return 0; } $project->ensureFull(); $project->update(array($property => $value)); $this->stdErr->writeln("Property <info>{$property}</info> set to: " . $this->formatter->format($value, $property)); $this->getProjects(true); return 0; }
/** * @param string $property * @param string $value * @param Project $project * @param bool $noWait * * @return int */ protected function setProperty($property, $value, Project $project, $noWait) { if (!$this->validateValue($property, $value)) { return 1; } $type = $this->getType($property); if ($type === 'boolean' && $value === 'false') { $value = false; } settype($value, $type); $currentValue = $project->getProperty($property); if ($currentValue === $value) { $this->stdErr->writeln("Property <info>{$property}</info> already set as: " . $this->formatter->format($value, $property)); return 0; } $project->ensureFull(); $result = $project->update([$property => $value]); $this->stdErr->writeln("Property <info>{$property}</info> set to: " . $this->formatter->format($value, $property)); $this->api()->clearProjectsCache(); $success = true; if (!$noWait) { $success = ActivityUtil::waitMultiple($result->getActivities(), $this->stdErr, $project); } return $success ? 0 : 1; }