composers.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. return array(
  3. /*
  4. |--------------------------------------------------------------------------
  5. | View Names & Composers
  6. |--------------------------------------------------------------------------
  7. |
  8. | Named views give you beautiful syntax when working with your views.
  9. |
  10. | Here's how to define a named view:
  11. |
  12. | 'home.index' => array('name' => 'home')
  13. |
  14. | Now, you can create an instance of that view using the very expressive
  15. | View::of dynamic method. Take a look at this example:
  16. |
  17. | return View::of_home();
  18. |
  19. | View composers provide a convenient way to add common elements to a view
  20. | each time it is created. For example, you may wish to bind a header and
  21. | footer partial each time the view is created.
  22. |
  23. | The composer will receive an instance of the view being created, and is
  24. | free to modify the view however you wish. Here is how to define one:
  25. |
  26. | 'home.index' => function($view)
  27. | {
  28. | //
  29. | }
  30. |
  31. | Of course, you may define a view name and a composer for a single view:
  32. |
  33. | 'home.index' => array('name' => 'home', function($view)
  34. | {
  35. | //
  36. | })
  37. |
  38. */
  39. 'home.index' => array('name' => 'home', function($view)
  40. {
  41. // This composer is called for the "home.index" view.
  42. }),
  43. );