Skip to content

Upgrade guide

Nicolas Widart edited this page Jun 21, 2015 · 8 revisions

Upgrade 1.1 -> 2.0

Architectural changes

  • The purpose of the SidebarManager is changed. The manager is now only responsible for registering the Sidebar, not for building.
  • Instead of directly building the menu in $manager->build(), you will have to create a new class which implements Maatwebsite\Sidebar\Sidebar. Register this custom Sidebar with the manager: $manager->register(YourSidebar::class); (See full example in Wiki)
  • To render your Sidebar (in a view creator for example) you will have to inject your custom Sidebar class and Maatwebsite\Sidebar\Presentation\SidebarRenderer and render like $this->renderer->render($this->sidebar) (See full example in Wiki)
  • It's no longer possible to use multiple view composers to fill the sidebar, due to caching implementation. Instead create a new class that extends Maatwebsite\Sidebar\SidebarExtender and add it to your Sidebar. (See full example in Wiki)
  • To resolve the sidebars you need to add 'Maatwebsite\Sidebar\Middleware\ResolveSidebars' to your middlewares in App\Http\Kernel

Syntax changes

  • addItem() -> item()
  • Magic getters and setters are removed. $group->weight = 0 -> $group->weight(0);
  • $badge->color = '' -> $badge->setClass();
  • $badge->value = '' -> $badge->setValue();
  • Class SidebarGroup -> interface Group
  • Class SidebarItem -> interface Item
  • Class SidebarBadge -> interface Badge
  • Class SidebarAppend -> interface Append