getDefault() public static méthode

public static getDefault ( string $name, mixed $default = null ) : mixed
$name string
$default mixed
Résultat mixed
Exemple #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(Input $input, Output $output)
 {
     $stage = $input->hasArgument('stage') ? $input->getArgument('stage') : null;
     $tasks = $this->deployer->getScriptManager()->getTasks($this->getName(), $stage);
     $servers = $this->deployer->getStageStrategy()->getServers($stage);
     $environments = iterator_to_array($this->deployer->environments);
     if (isset($this->executor)) {
         $executor = $this->executor;
     } else {
         if ($input->getOption('parallel')) {
             $executor = new ParallelExecutor($this->deployer->getConsole()->getUserDefinition());
         } else {
             $executor = new SeriesExecutor();
         }
     }
     try {
         $executor->run($tasks, $servers, $environments, $input, $output);
     } catch (\Exception $exception) {
         \Deployer\logger($exception->getMessage(), Logger::ERROR);
         // Check if we have tasks to execute on failure.
         if ($this->deployer['onFailure']->has($this->getName())) {
             $taskName = $this->deployer['onFailure']->get($this->getName());
             $tasks = $this->deployer->getScriptManager()->getTasks($taskName, $stage);
             $executor->run($tasks, $servers, $environments, $input, $output);
         }
         throw $exception;
     }
     if (Deployer::hasDefault('terminate_message')) {
         $output->writeln(Deployer::getDefault('terminate_message'));
     }
 }
Exemple #2
0
/**
 * Get configuration value.
 *
 * @param string $name
 * @param mixed|null $default
 * @return mixed
 */
function get($name, $default = null)
{
    if (Context::get() === false) {
        return Deployer::getDefault($name, $default);
    } else {
        return Context::get()->getEnvironment()->get($name, $default);
    }
}