Skip to content

Commit

Permalink
Tweak controller layout resolution.
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Otwell <[email protected]>
  • Loading branch information
taylorotwell committed Mar 5, 2012
1 parent 2b81497 commit 8da1c16
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions laravel/routing/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ abstract class Controller {
*/
const factory = 'laravel.controller.factory';

/**
* Create a new Controller instance.
*
* @return void
*/
public function __construct()
{
// 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($this->layout))
{
$this->layout = $this->layout();
}
}

/**
* Call an action method on a controller.
*
Expand Down Expand Up @@ -141,22 +157,12 @@ public static function resolve($bundle, $controller)
// by convention out of the bundle's controller directory.
if (Event::listeners(static::factory))
{
$controller = Event::first(static::factory, $controller);
return Event::first(static::factory, $controller);
}
else
{
$controller = new $controller;
return 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;
}

/**
Expand Down

0 comments on commit 8da1c16

Please sign in to comment.