本文整理汇总了PHP中Laravel\Bundle::option方法的典型用法代码示例。如果您正苦于以下问题:PHP Bundle::option方法的具体用法?PHP Bundle::option怎么用?PHP Bundle::option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Laravel\Bundle
的用法示例。
在下文中一共展示了Bundle::option方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: controller
/**
* Register a controller with the router.
*
* @param string|array $controllers
* @param string|array $defaults
* @param bool $https
* @return void
*/
public static function controller($controllers, $defaults = 'index', $https = null)
{
foreach ((array) $controllers as $identifier) {
list($bundle, $controller) = Bundle::parse($identifier);
// First we need to replace the dots with slashes in the controller name
// so that it is in directory format. The dots allow the developer to use
// a cleaner syntax when specifying the controller. We will also grab the
// root URI for the controller's bundle.
$controller = str_replace('.', '/', $controller);
$root = Bundle::option($bundle, 'handles');
// If the controller is a "home" controller, we'll need to also build an
// index method route for the controller. We'll remove "home" from the
// route root and setup a route to point to the index method.
if (ends_with($controller, 'home')) {
static::root($identifier, $controller, $root);
}
// The number of method arguments allowed for a controller is set by a
// "segments" constant on this class which allows for the developer to
// increase or decrease the limit on method arguments.
$wildcards = static::repeat('(:any?)', static::$segments);
// Once we have the path and root URI we can build a simple route for
// the controller that should handle a conventional controller route
// setup of controller/method/segment/segment, etc.
$pattern = trim("{$root}/{$controller}/{$wildcards}", '/');
// Finally we can build the "uses" clause and the attributes for the
// controller route and register it with the router with a wildcard
// method so it is available on every request method.
$uses = "{$identifier}@(:1)";
$attributes = compact('uses', 'defaults', 'https');
static::register('*', $pattern, $attributes);
}
}
示例2: controller
public static function controller($controllers, $defaults = 'index', $https = null)
{
foreach ((array) $controllers as $identifier) {
list($bundle, $controller) = Bundle::parse($identifier);
$controller = str_replace('.', '/', $controller);
$root = Bundle::option($bundle, 'handles');
if (ends_with($controller, 'home')) {
static::root($identifier, $controller, $root);
}
$wildcards = static::repeat('(:any?)', static::$segments);
$pattern = trim("{$root}/{$controller}/{$wildcards}", '/');
$uses = "{$identifier}@(:1)";
$attributes = compact('uses', 'defaults', 'https');
static::register('*', $pattern, $attributes);
}
}