/** * @{inheritDoc} */ public function authorize(SessionInterface $session) { $connection = $session->getConnection(); $credential = $this->getCredential(); list($type, $data) = $this->parse($credential); array_unshift($data, $connection); call_user_func_array(self::FUNCTION_PREFIX . $type, array_filter($data)); $session->setConnection($connection); return $session->valid(); }
/** * Main Runner * * @param dynamic */ protected function doRun() { $result = 0; $args = func_get_args(); $host = $this->session->getHost(); if (count($args) === 3) { list($method, $params, $retval) = $args; // Strip namespace $method = trim(str_replace(__NAMESPACE__, '', $method), '\\'); $command = $method . ' => [' . implode(' , ', $params) . ']'; $this->printOut('<comment>' . $host . '</comment> < <info>' . $command . '</info>'); // Initial result evaluation $result = $retval; $halt = $result == false; // Prints process information // @codeCoverageIgnoreStart if ($halt) { $this->printOut('<error>Aborted</error>'); } else { if (is_string($retval) || is_array($retval)) { if (is_array($retval)) { foreach ($retval as $key => $val) { if (!is_numeric($key)) { $resultDioArray[] = $key . ':' . $val; } } } else { $resultDioArray = array_filter(explode("\n", $retval)); } foreach ($resultDioArray as $i => $resultDioLine) { $this->printOut(($i === 0 ? '<comment>' . $host . '</comment>' : str_pad(' ', strlen($host))) . ' > <info>' . $resultDioLine . '</info>'); } } else { $this->printOut('<comment>' . $host . '</comment> > <info>[OK]</info>'); } } // @codeCoverageIgnoreEnd } return $result; }
/** * @{inheritDoc} */ public function get($remoteFile = '', $localFile = '') { return $this->doRun(__METHOD__, func_get_args(), ssh2_scp_recv($this->session->getConnection(), $remoteFile, $localFile)); }