/** * Setup test data. * * @return void */ public function setUp() { parent::setUp(); Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]); $this->View = $this->getMock('Union\\Core\\View\\AppView', ['append']); $this->Nav = new NavHelper($this->View); Nav::add('test_menu', 'dashboard', ['title' => __d('union', 'Dashboard'), 'weight' => 0, 'icon' => 'dashboard', 'url' => 'link', 'children' => ['link-1' => ['title' => __d('union', 'Children 1'), 'weight' => 0, 'url' => 'link-2']]]); Nav::add('test_menu_2', 'dashboard', ['title' => __d('union', 'Dashboard'), 'weight' => 0, 'class' => 'customClass', 'liClass' => 'customLiClass', 'icon' => 'dashboard', 'url' => 'link', 'children' => ['link-1' => ['title' => __d('union', 'Children 1'), 'weight' => 0, 'url' => 'link-2']]]); }
<?php /** * UnionCMS Core * * This file is part of the of the simple cms based on CakePHP 3. * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * @package Core * @license MIT * @copyright MIT License http://www.opensource.org/licenses/mit-license.php * @link https://github.com/UnionCMS/Core * @author Sergey Kalistratov <*****@*****.**> */ use Union\Core\Nav; use Union\Core\Plugin; $plugin = 'Union/Core'; Nav::add('sidebar', 'dashboard', ['title' => __d('union', 'Dashboard'), 'weight' => 0, 'icon' => 'dashboard', 'url' => ['plugin' => $plugin, 'controller' => 'Union', 'action' => 'dashboard']]); Nav::add('sidebar', 'system', ['title' => __d('union', 'System'), 'weight' => 1, 'icon' => 'cog', 'children' => ['global-config' => ['title' => __d('union', 'Global config'), 'url' => ['plugin' => 'Union/Extensions', 'controller' => 'Plugins', 'action' => 'config', Plugin::alias($plugin)]]]]);
/** * Test remove items. * * @return void */ public function testRemove() { $options = ['title' => 'Bar', 'path' => '/my/path']; Nav::add('remove', 'simple', $options); $expected = ['simple' => Hash::merge(Nav::getDefaults(), $options)]; $this->assertSame($expected, Nav::items('remove')); Nav::remove('remove'); $this->assertSame([], Nav::items('remove')); }
<?php /** * UnionCMS Community * * This file is part of the of the simple cms based on CakePHP 3. * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * @package Community * @license MIT * @copyright MIT License http://www.opensource.org/licenses/mit-license.php * @link https://github.com/UnionCMS/Community * @author Sergey Kalistratov <*****@*****.**> */ use Union\Core\Nav; use Union\Core\Plugin; $plugin = 'Union/Community'; Nav::add('sidebar', 'community', ['title' => __d('community', 'Community'), 'weight' => 50, 'icon' => 'group', 'children' => ['roles' => ['title' => __d('community', 'Groups'), 'weight' => 0, 'url' => ['plugin' => $plugin, 'controller' => 'Roles', 'action' => 'index']], 'users' => ['title' => __d('community', 'Users'), 'weight' => 10, 'url' => ['plugin' => $plugin, 'controller' => 'Users', 'action' => 'index']], 'permissions' => ['title' => __d('community', 'Permissions'), 'weight' => 15, 'url' => ['plugin' => $plugin, 'controller' => 'Acl', 'action' => 'permissions']], 'config' => ['title' => __d('union', 'Configure'), 'weight' => 20, 'url' => ['plugin' => 'Union/Extensions', 'controller' => 'Plugins', 'action' => 'config', Plugin::alias($plugin)]]]]);
/** * User menu for backend. * * @return void */ protected function _backendMenu() { Nav::add('user_nav', 'user', ['weight' => 10, 'icon' => 'user', 'liClass' => 'user user-menu', 'title' => $this->_controller->Auth->user('username'), 'children' => ['profile' => ['weight' => 10, 'title' => __d('community', 'Profile'), 'url' => ['plugin' => 'Union/Community', 'controller' => 'Users', 'action' => 'edit', $this->_controller->Auth->user('id')]], 'logout' => ['weight' => 100, 'title' => __d('community', 'Logout'), 'url' => ['plugin' => 'Union/Community', 'controller' => 'Users', 'action' => 'logout']]]]); }