diff --git a/src/Frozennode/Administrator/Config/Factory.php b/src/Frozennode/Administrator/Config/Factory.php index f2319fb73..9ee447769 100644 --- a/src/Frozennode/Administrator/Config/Factory.php +++ b/src/Frozennode/Administrator/Config/Factory.php @@ -64,6 +64,13 @@ class Factory { */ protected $pagePrefix = 'page.'; + /** + * The route menu prefix + * + * @var string + */ + protected $routePrefix = 'route.'; + /** * The rules array * @@ -124,7 +131,7 @@ public function make($name, $primary = false) $options = $this->searchMenu($name); //return the config object if the file/array was found, or false if it wasn't - $config = $options ? $this->getItemConfigObject($options) : ($this->type === 'page' ? true : false); + $config = $options ? $this->getItemConfigObject($options) : (($this->type === 'page' || $this->type === 'route' ) ? true : false); //set the primary config $this->config = $primary ? $config : $this->config; @@ -176,6 +183,11 @@ public function parseType($name) { return $this->type = 'page'; } + //otherwise if the name is prefixed with the route prefix + elseif (strpos($name, $this->routePrefix) === 0) + { + return $this->type = 'route'; + } //otherwise it's a model else { @@ -242,6 +254,14 @@ public function getPagePrefix() return $this->pagePrefix; } + /** + * Gets the prefix for the currently-searched item + */ + public function getRoutePrefix() + { + return $this->routePrefix; + } + /** * Gets the prefix for the currently-searched item */ @@ -255,6 +275,10 @@ public function getPrefix() { return $this->pagePrefix; } + else if ($this->type === 'route') + { + return $this->routePrefix; + } return ''; } diff --git a/src/config/administrator.php b/src/config/administrator.php index 888dab320..940820e10 100644 --- a/src/config/administrator.php +++ b/src/config/administrator.php @@ -47,11 +47,11 @@ /** * The menu structure of the site. For models, you should either supply the name of a model config file or an array of names of model config * files. The same applies to settings config files, except you must prepend 'settings.' to the settings config file name. You can also add - * custom pages by prepending a view path with 'page.'. By providing an array of names, you can group certain models or settings pages + * custom pages by prepending a view path with 'page.'. You can also add arbitrary named routes by prepending a route with '.route'. By providing an array of names, you can group certain models or settings pages * together. Each name needs to either have a config file in your model config path, settings config path with the same name, or a path to a * fully-qualified Laravel view. So 'users' would require a 'users.php' file in your model config path, 'settings.site' would require a - * 'site.php' file in your settings config path, and 'page.foo.test' would require a 'test.php' or 'test.blade.php' file in a 'foo' directory - * inside your view directory. + * 'site.php' file in your settings config path, 'page.foo.test' would require a 'test.php' or 'test.blade.php' file in a 'foo' directory + * inside your view directory, and 'route.tools' would require a named route 'tools' configured in your routes file. * * @type array * diff --git a/src/viewComposers.php b/src/viewComposers.php index c7c8ce8cd..ac6a8ff9f 100644 --- a/src/viewComposers.php +++ b/src/viewComposers.php @@ -60,6 +60,7 @@ $view->menu = app('admin_menu')->getMenu(); $view->settingsPrefix = app('admin_config_factory')->getSettingsPrefix(); $view->pagePrefix = app('admin_config_factory')->getPagePrefix(); + $view->routePrefix = app('admin_config_factory')->getRoutePrefix(); $view->configType = app()->bound('itemconfig') ? app('itemconfig')->getType() : false; }); diff --git a/src/views/partials/menu_item.blade.php b/src/views/partials/menu_item.blade.php index 1233a504a..e14f92480 100644 --- a/src/views/partials/menu_item.blade.php +++ b/src/views/partials/menu_item.blade.php @@ -7,7 +7,8 @@ 'item' => $subitem, 'key' => $k, 'settingsPrefix' => $settingsPrefix, - 'pagePrefix' => $pagePrefix + 'pagePrefix' => $pagePrefix, + 'routePrefix' => $routePrefix ))?> @endforeach @@ -18,6 +19,8 @@ {{$item}} @elseif (strpos($key, $pagePrefix) === 0) {{$item}} + @elseif (strpos($key, $routePrefix) === 0) + {{$item}} @else {{$item}} @endif diff --git a/tests/Config/ConfigFactoryTest.php b/tests/Config/ConfigFactoryTest.php index e890cbce1..2b94703a3 100644 --- a/tests/Config/ConfigFactoryTest.php +++ b/tests/Config/ConfigFactoryTest.php @@ -100,6 +100,13 @@ public function testParseTypeSettings() $this->assertEquals($factory->getType(), 'settings'); } + public function testParseTypeRoute() + { + $factory = new Factory($this->validator, $this->validator, array()); + $factory->parseType('route.something'); + $this->assertEquals($factory->getType(), 'route'); + } + public function testModelInMenu() { $name = 'some_model';