Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-register menus from 'config/menus.php' #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/Http/Lumberjack.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http;

use Rareloop\Lumberjack\Http\Lumberjack as LumberjackCore;
use Rareloop\Lumberjack\Facades\Config;
use App\Menu\Menu;

class Lumberjack extends LumberjackCore
Expand All @@ -18,7 +19,13 @@ public function addToContext($context)
// the context, you can get items from it in a way that is a little smoother and more
// versatile than Wordpress's wp_nav_menu. (You need never again rely on a
// crazy "Walker Function!")
$context['menu'] = new Menu('main-nav');

// Auto-register menus from 'config/menus.php'
if (!empty( $menus = Config::get('menus.menus') ) ) {
foreach( $menus as $key => $value ) {
$context[$key] = new Menu( $key );
}
}

return $context;
}
Expand Down