Commit 893bb838 authored by Taylor Otwell's avatar Taylor Otwell

added application access to composers.

parent 5e40e296
......@@ -39,7 +39,7 @@ return array(
|
*/
'home.index' => array('name' => 'home', function($view)
'home.index' => array('name' => 'home', function($laravel, $view)
{
//
}),
......
......@@ -158,11 +158,17 @@ return array(
}),
'laravel.view' => array('singleton' => true, 'resolver' => function()
'laravel.view' => array('singleton' => true, 'resolver' => function($container)
{
require_once SYS_PATH.'view'.EXT;
return new View_Factory(VIEW_PATH, new View_Composer(require APP_PATH.'composers'.EXT));
return new View_Factory($container->resolve('laravel.view.composer'), VIEW_PATH);
}),
'laravel.view.composer' => array('resolver' => function($container)
{
return new View_Composer($container->resolve('laravel.application'), require APP_PATH.'composers'.EXT);
}),
/*
......
......@@ -8,6 +8,13 @@
*/
class View_Composer {
/**
* The application instance.
*
* @var Application
*/
protected $application;
/**
* The view composers.
*
......@@ -21,8 +28,9 @@ class View_Composer {
* @param array $composers
* @return void
*/
public function __construct($composers)
public function __construct(Application $application, $composers)
{
$this->application = $application;
$this->composers = $composers;
}
......@@ -52,7 +60,7 @@ class View_Composer {
{
foreach ((array) $this->composers[$view->view] as $key => $value)
{
if ($value instanceof \Closure) return call_user_func($value, $view);
if ($value instanceof \Closure) return call_user_func($value, $this->application, $view);
}
}
}
......@@ -67,30 +75,30 @@ class View_Composer {
class View_Factory {
/**
* The directory containing the views.
* The view composer instance.
*
* @var string
* @var View_Composer
*/
protected $path;
protected $composer;
/**
* The view composer instance.
* The directory containing the views.
*
* @var View_Composer
* @var string
*/
protected $composer;
protected $path;
/**
* Create a new view factory instance.
*
* @param array $composers
* @param string $path
* @param View_Composer $composer
* @param string $path
* @return void
*/
public function __construct($path, View_Composer $composer)
public function __construct(View_Composer $composer, $path)
{
$this->path = $path;
$this->composer = $composer;
$this->path = $path;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment