Пример #1
0
 /**
  * @param string
  *
  * @return mixed
  * @throws VerificationFailedException
  */
 public function importKey($keyId, $key)
 {
     if (!$this->input->confirm(sprintf('Import key %s?', $keyId))) {
         throw new VerificationFailedException(sprintf('User declined import of key %s', $keyId));
     }
     return $this->keyImporter->importKey($key);
 }
Пример #2
0
Файл: App.php Проект: pagon/core
 /**
  * Register or run error
  *
  * @param string   $type
  * @param callable $route
  * @throws \InvalidArgumentException
  */
 public function handleError($type, $route = null)
 {
     if (!isset($this->injectors['errors'][$type])) {
         throw new \InvalidArgumentException('Unknown error type "' . $type . '" to call');
     }
     if (is_string($route) && is_subclass_of($route, Route::_CLASS_, true) || $route instanceof \Closure) {
         $this->injectors['errors'][$type][2] = $route;
     } else {
         ob_get_level() && ob_clean();
         ob_start();
         if (empty($this->injectors['errors'][$type][2]) || !$this->router->run($this->injectors['errors'][$type][2], array('error' => array('type' => $type, 'error' => $route, 'message' => $this->injectors['errors'][$type])))) {
             if ($this->injectors['cli']) {
                 $this->halt($this->injectors['errors'][$type][0], $this->injectors['errors'][$type][1]);
             } else {
                 $this->output->status($this->injectors['errors'][$type][0]);
                 $this->render('pagon/views/error.php', array('title' => $this->injectors['errors'][$type][1], 'message' => $route ? $route instanceof \Exception ? $route->getMessage() : (string) $route : 'Could not ' . $this->input->method() . ' ' . $this->input->path()));
                 $this->stop();
             }
         }
     }
 }