本文整理汇总了PHP中Illuminate\Routing\RouteCollection::getByName方法的典型用法代码示例。如果您正苦于以下问题:PHP RouteCollection::getByName方法的具体用法?PHP RouteCollection::getByName怎么用?PHP RouteCollection::getByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Routing\RouteCollection
的用法示例。
在下文中一共展示了RouteCollection::getByName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: route
/**
* Get the URL to a named route.
*
* @param string $name
* @param mixed $parameters
* @param bool $absolute
* @return string
*
* @throws \InvalidArgumentException
*/
public function route($name, $parameters = [], $absolute = true)
{
if (!is_null($route = $this->routes->getByName($name))) {
return $this->toRoute($route, $parameters, $absolute);
}
throw new InvalidArgumentException("Route [{$name}] not defined.");
}
示例2: route
/**
* Get the URL to a named route.
*
* @param string $name
* @param mixed $parameters
* @param bool $absolute
* @param \Illuminate\Routing\Route $route
* @return string
*
* @throws \InvalidArgumentException
*/
public function route($name, $parameters = array(), $absolute = true, $route = null)
{
$route = $route ?: $this->routes->getByName($name);
$parameters = (array) $parameters;
if (!is_null($route)) {
return $this->toRoute($route, $parameters, $absolute);
}
throw new InvalidArgumentException("Route [{$name}] not defined.");
}
示例3: makesByType
/**
* Make permission instances by type
*
* @param string $type type string
* @param MemberEntityInterface $user user instance
* @param string $siteKey site key
* @return Permission[]
* @throws NotMatchedInstanceException
*/
public function makesByType($type, MemberEntityInterface $user = null, $siteKey = 'default')
{
$user = $user ?: $this->auth->user();
$permissions = [];
$registereds = $this->repo->fetchByType($siteKey, $type);
foreach ($registereds as $registered) {
$ancestors = array_filter($registereds, function ($item) use($registered) {
$itemNames = explode('.', $item->name);
$registeredNames = explode('.', $registered->name);
if (count($itemNames) >= count($registeredNames)) {
return false;
}
for ($i = 0; $i < count($itemNames); $i++) {
if ($itemNames[$i] !== $registeredNames[$i]) {
return false;
}
}
return true;
});
if (count($ancestors) > 0) {
uasort($ancestors, [$this, 'cmp']);
}
foreach ($ancestors as $ancestor) {
$registered->addParent($ancestor);
}
if (isset($this->extends[$type]) === true) {
$permission = $this->extends[$type]($registered->name, $user, $registered);
if ($permission instanceof Permission === false) {
throw new NotMatchedInstanceException(['type' => $type]);
}
$permissions[$registered->name] = $permission;
} else {
switch ($type) {
case 'route':
$route = $this->routes->getByName($registered->name);
$permissions[$registered->name] = new RoutePermission($route, $user, $registered);
break;
case 'instance':
$permissions[$registered->name] = new InstancePermission($registered->name, $user, $registered);
break;
}
}
}
return $permissions;
}
示例4: resolveControllerByName
/**
* @param RouteCollection $routes
*
* @return Controller
*
* @throws ShapeShifterException
*/
protected function resolveControllerByName(RouteCollection $routes)
{
$contr = $routes->getByName($this->destination);
if (!$contr) {
throw new ShapeShifterException("Route [{$this->destination}] does not exist");
}
list($class) = explode('@', $contr->getActionName());
return app($class);
}
示例5: assertHasNamedRoute
protected function assertHasNamedRoute($name)
{
$this->getRoutes();
$this->assertNotNull($this->routeCol->getByName($name), "Missing named route {$name}");
}