public function get($name) { $name = $this->resolveAlias($name); if (isset($this->cache[$name])) { return $this->cache[$name]; } if (isset($this->loading[$name])) { throw new Exception\CircularReferenceException($name, array_keys($this->loading)); } $this->loading[$name] = true; if (isset($this->services[$name])) { $service = $this->services[$name]; } else { throw new Exception\UnregisteredService($name, $this); } $service = $service($this); if (isset($this->types[$name])) { foreach ($this->types[$name] as $type) { if (!$service instanceof $type) { Exception::toss('The service "%s" is required to be an instance of "%s". Instance of "%s" supplied.', $name, $type, get_class($service)); } } } unset($this->loading[$name]); if (isset($this->transient[$name])) { return $service; } return $this->cache[$name] = $service; }
public function format($name, array $params = []) { foreach ($this->routers as $router) { if ($router->has($name)) { return $router->get($name)->format($params); } } Exception::toss('The route "%s" cannot be formatted because it does not exist.', $name); }
public function getViewContentType($view) { if (!is_object($view)) { Exception::toss('Cannot detect content type for a non-object.'); } $view = get_class($view); if (isset($this->viewContentTypeMap[$view])) { return $this->viewContentTypeMap[$view]; } return self::HTML; }