本文整理匯總了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);
}
}