Skip to content

Commit

Permalink
Updated example of View Composer : Correction
Browse files Browse the repository at this point in the history
The current example throws an exception as it is no longer an event object and right now the callback is given the view object.
  • Loading branch information
raftalks committed Feb 8, 2013
1 parent a696f5a commit 5830005
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions responses.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,18 @@ View composers are callbacks or class methods that are called when a view is cre

**Defining A View Composer**

View::composer('profile', function($event)
View::composer('profile', function($view)
{
$event->view->with('count', User::count());
$view->with('count', User::count());
});

Now each time the `profile` view is created, the `count` data will be bound to the view.

You may also attach a view composer to multiple views at once:

View::composer(array('profile','dashboard'), function($event)
View::composer(array('profile','dashboard'), function($view)
{
$event->view->with('count', User::count());
$view->with('count', User::count());
});

If you would rather use a class based composer, which will provide the benefits of being resolved through the application [IoC container](/docs/ioc), you may do so:
Expand All @@ -141,9 +141,9 @@ A view composer class should be defined like so:

class ProfileComposer {

public function compose($event)
public function compose($view)
{
$event->view->with('count', User::count());
$view->with('count', User::count());
}

}
Expand Down

0 comments on commit 5830005

Please sign in to comment.