本文整理汇总了PHP中Exception::toss方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::toss方法的具体用法?PHP Exception::toss怎么用?PHP Exception::toss使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::toss方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
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;
}
示例2: format
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);
}
示例3: getViewContentType
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;
}