/** * @param string $property * @param string $value * @param Environment $environment * * @return int */ protected function setProperty($property, $value, Environment $environment) { if (!$this->validateValue($property, $value)) { return 1; } $type = $this->getType($property); if ($type === 'boolean' && $value === 'false') { $value = false; } settype($value, $type); $currentValue = $environment->getProperty($property, false); if ($currentValue === $value) { $this->stdErr->writeln("Property <info>{$property}</info> already set as: " . $this->formatter->format($environment->getProperty($property, false), $property)); return 0; } $environment->update(array($property => $value)); $this->stdErr->writeln("Property <info>{$property}</info> set to: " . $this->formatter->format($environment[$property], $property)); $rebuildProperties = array('enable_smtp', 'restrict_robots'); if (in_array($property, $rebuildProperties) && !$environment->getLastActivity()) { $this->rebuildWarning(); } // Refresh the stored environments. $this->getEnvironments($this->getSelectedProject(), true); return 0; }
/** * @param string $property * @param string $value * @param Environment $environment * * @return int */ protected function setProperty($property, $value, Environment $environment) { if (!$this->validateValue($property, $value)) { return 1; } $type = $this->getType($property); if ($type === 'boolean' && $value === 'false') { $value = false; } settype($value, $type); $currentValue = $environment->getProperty($property, false); if ($currentValue === $value) { $this->stdErr->writeln("Property <info>{$property}</info> already set as: " . $environment->getProperty($property, false)); return 0; } $environment->update(array($property => $value)); $this->stdErr->writeln("Property <info>{$property}</info> set to: " . $environment[$property]); if ($property === 'enable_smtp' && !$environment->getLastActivity()) { $this->rebuildWarning(); } return 0; }
/** * @param string $property * @param string $value * @param Environment $environment * @param bool $noWait * * @return int */ protected function setProperty($property, $value, Environment $environment, $noWait) { if (!$this->validateValue($property, $value)) { return 1; } $type = $this->getType($property); if ($type === 'boolean' && $value === 'false') { $value = false; } settype($value, $type); $currentValue = $environment->getProperty($property, false); if ($currentValue === $value) { $this->stdErr->writeln("Property <info>{$property}</info> already set as: " . $this->formatter->format($environment->getProperty($property, false), $property)); return 0; } $result = $environment->update([$property => $value]); $this->stdErr->writeln("Property <info>{$property}</info> set to: " . $this->formatter->format($environment->{$property}, $property)); $this->api()->clearEnvironmentsCache($environment->project); $rebuildProperties = ['enable_smtp', 'restrict_robots']; $success = true; if ($result->countActivities() && !$noWait) { $success = ActivityUtil::waitMultiple($result->getActivities(), $this->stdErr, $this->getSelectedProject()); } elseif (!$result->countActivities() && in_array($property, $rebuildProperties)) { $this->rebuildWarning(); } return $success ? 0 : 1; }