本文整理匯總了PHP中Laravel\Bundle::identifier方法的典型用法代碼示例。如果您正苦於以下問題:PHP Bundle::identifier方法的具體用法?PHP Bundle::identifier怎麽用?PHP Bundle::identifier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Laravel\Bundle
的用法示例。
在下文中一共展示了Bundle::identifier方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: resolve
/**
* Resolve a bundle and controller name to a controller instance.
*
* @param string $bundle
* @param string $controller
* @return Controller
*/
public static function resolve($bundle, $controller)
{
if (!static::load($bundle, $controller)) {
return;
}
$identifier = Bundle::identifier($bundle, $controller);
// If the controller is registered in the IoC container, we will resolve
// it out of the container. Using constructor injection on controllers
// via the container allows more flexible applications.
$resolver = 'controller: ' . $identifier;
if (IoC::registered($resolver)) {
return IoC::resolve($resolver);
}
$controller = static::format($bundle, $controller);
// If we couldn't resolve the controller out of the IoC container we'll
// format the controller name into its proper class name and load it
// by convention out of the bundle's controller directory.
if (Event::listeners(static::factory)) {
return Event::first(static::factory, $controller);
} else {
return new $controller();
}
}
示例2: resolve
/**
* Resolve a bundle and controller name to a controller instance.
*
* @param string $bundle
* @param string $controller
* @return Controller
*/
public static function resolve($bundle, $controller)
{
if (!static::load($bundle, $controller)) {
return;
}
$identifier = Bundle::identifier($bundle, $controller);
// If the controller is registered in the IoC container, we will resolve
// it out of the container. Using constructor injection on controllers
// via the container allows more flexible applications.
$resolver = 'controller: ' . $identifier;
if (IoC::registered($resolver)) {
return IoC::resolve($resolver);
}
// If we couldn't resolve the controller out of the IoC container we'll
// format the controller name into its proper class name and load it
// by convention out of the bundle's controller directory.
$controller = static::format($bundle, $controller);
$controller = new $controller();
// If the controller has specified a layout to be used when rendering
// views, we will instantiate the layout instance and set it to the
// layout property, replacing the string layout name.
if (!is_null($controller->layout)) {
$controller->layout = $controller->layout();
}
return $controller;
}
示例3: resolve
/**
* Resolve an instance of the given task name.
*
* <code>
* // Resolve an instance of a task
* $task = Command::resolve('application', 'migrate');
*
* // Resolve an instance of a task wtihin a bundle
* $task = Command::resolve('bundle', 'foo');
* </code>
*
* @param string $bundle
* @param string $task
* @return object
*/
public static function resolve($bundle, $task)
{
$identifier = Bundle::identifier($bundle, $task);
// First we'll check to see if the task has been registered in the
// application IoC container. This allows all dependencies to be
// injected into tasks for more testability.
if (IoC::registered("task: {$identifier}")) {
return IoC::resolve("task: {$identifier}");
}
// If the task file exists, we'll format the bundle and task name
// into a task class name and resolve an instance of the so that
// the requested method may be executed.
if (file_exists($path = Bundle::path($bundle) . 'tasks/' . $task . EXT)) {
require $path;
$task = static::format($bundle, $task);
return new $task();
}
}
示例4: resolve
public static function resolve($bundle, $controller)
{
if (!static::load($bundle, $controller)) {
return;
}
$identifier = Bundle::identifier($bundle, $controller);
$resolver = 'controller: ' . $identifier;
if (IoC::registered($resolver)) {
return IoC::resolve($resolver);
}
$controller = static::format($bundle, $controller);
if (Event::listeners(static::factory)) {
return Event::first(static::factory, $controller);
} else {
return new $controller();
}
}