本文整理汇总了PHP中Illuminate\Routing\Route::setHost方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::setHost方法的具体用法?PHP Route::setHost怎么用?PHP Route::setHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Routing\Route
的用法示例。
在下文中一共展示了Route::setHost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setAttributes
/**
* Set the attributes and requirements on the route.
*
* @param \Illuminate\Routing\Route $route
* @param array $action
* @param array $optional
* @return void
*/
protected function setAttributes(Route $route, $action, $optional)
{
// First we will set the requirement for the HTTP schemes. Some routes may
// only respond to requests using the HTTPS scheme, while others might
// respond to all, regardless of the scheme, so we'll set that here.
if (in_array('https', $action)) {
$route->setRequirement('_scheme', 'https');
}
if (in_array('http', $action)) {
$route->setRequirement('_scheme', 'http');
}
// Once the scheme requirements have been made, we will set the before and
// after middleware options, which will be used to run any middlewares
// by the consuming library, making halting the request cycles easy.
if (isset($action['before'])) {
$route->setBeforeFilters($action['before']);
}
if (isset($action['after'])) {
$route->setAfterFilters($action['after']);
}
// If there is a "uses" key on the route it means it is using a controller
// instead of a Closures route. So, we'll need to set that as an option
// on the route so we can easily do reverse routing ot the route URI.
if (isset($action['uses'])) {
$route->setOption('_uses', $action['uses']);
}
if (isset($action['domain'])) {
$route->setHost($action['domain']);
}
// Finally we will go through and set all of the default variables to null
// so the developer doesn't have to manually specify one each time they
// are declared on a route. This is simply for developer convenience.
foreach ($optional as $key) {
$route->setDefault($key, null);
}
}