added support for controller factories.
This commit is contained in:
parent
86fa595317
commit
e70261e962
|
@ -83,7 +83,7 @@ public static function fire($event, $parameters = array())
|
||||||
{
|
{
|
||||||
foreach (static::$events[$event] as $callback)
|
foreach (static::$events[$event] as $callback)
|
||||||
{
|
{
|
||||||
$responses[] = call_user_func_array($callback, $parameters);
|
$responses[] = call_user_func_array($callback, (array) $parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,13 @@ abstract class Controller {
|
||||||
*/
|
*/
|
||||||
protected $filters = array();
|
protected $filters = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The event name for the Laravel controller factory.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const factory = 'laravel.controller.factory';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call an action method on a controller.
|
* Call an action method on a controller.
|
||||||
*
|
*
|
||||||
|
@ -127,12 +134,19 @@ public static function resolve($bundle, $controller)
|
||||||
return IoC::resolve($resolver);
|
return IoC::resolve($resolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$controller = static::format($bundle, $controller);
|
||||||
|
|
||||||
// If we couldn't resolve the controller out of the IoC container we'll
|
// 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
|
// format the controller name into its proper class name and load it
|
||||||
// by convention out of the bundle's controller directory.
|
// by convention out of the bundle's controller directory.
|
||||||
$controller = static::format($bundle, $controller);
|
if (Event::listeners(static::factory))
|
||||||
|
{
|
||||||
|
$controller = Event::first(static::factory, $controller);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$controller = new $controller;
|
$controller = new $controller;
|
||||||
|
}
|
||||||
|
|
||||||
// If the controller has specified a layout to be used when rendering
|
// If the controller has specified a layout to be used when rendering
|
||||||
// views, we will instantiate the layout instance and set it to the
|
// views, we will instantiate the layout instance and set it to the
|
||||||
|
|
Loading…
Reference in New Issue