/** * @param array $config * @param string|null $task_prefix * @return array */ public function expandConfig(array $config, $task_prefix = null) { $result = []; $subtasks = []; if (!empty($config)) { $config = $this->expandCompositeTasks($config); foreach ($config as $task => $conf) { if (in_array($task, ['.events', '.task', '.description'], true)) { continue; } if (empty($task_prefix)) { self::$depends_prefix = $task; } $task_key = empty($task_prefix) ? $task : $task_prefix . $this->command->getDelimiter() . $task; if ($task !== '.depends' && is_array($conf) && !is_callable($conf)) { $subtasks = array_merge($subtasks, $this->expandConfig($conf, $task_key)); foreach ($conf as $k => $v) { if (!in_array($k, self::$reservedWords, true) && is_array($v) && !is_callable($v)) { unset($conf[$k]); } } } if (is_array($conf)) { foreach ($conf as $k => $v) { if ($k === '.depends' && !empty($conf[$k])) { foreach ($conf[$k] as $dependency_key => $dependency_name) { $conf[$k][$dependency_key] = str_replace('*', self::$depends_prefix, $dependency_name); } } } } if (!in_array($task, self::$reservedWords, true)) { $result[$task_key] = $conf; } } } $result = array_merge($result, $subtasks); ksort($result); return $result; }
/** * Send message to output * @param string $message * @param integer $indent * @param boolean $newLine */ protected function log($message, $indent = 0, $newLine = true) { $this->command->log($message, $this->indent($indent), $newLine); }