dev-master
9999999-devAdminBar plugin for CakeAdmin and CakePHP
The Requires
- php >=5.4.16
- cakephp/cakephp ~3.0
The Development Requires
Wallogit.com
2017 © Pedro Peláez
AdminBar plugin for CakeAdmin and CakePHP
This plugin generates an easy-to-use admin-bar on top of your application when you are logged in as administrator., (*1)
Note: This is a non-stable plugin for CakePHP 3.x at this time. It is currently under development and should be considered experimental., (*2)
You can install this plugin into your CakePHP application using composer., (*3)
The recommended way to install composer packages is:, (*4)
composer require cakemanager/cakeadmin-adminbar:dev-master
Now load the plugin with the command:, (*5)
$ bin/cake plugin load -r -b AdminBar
The last thing you need to do is to load the AdminBar.AdminBar-Component using:, (*6)
$this->loadComponent('AdminBar.AdminBar');
You can activate or deactivate the AdminBar in the settings-page in the backend., (*7)
Adding items is done via the Configure-class of CakePHP. Look at this example:, (*8)
Configure::write('AdminBar.goto_backend', [
'on' => [
'prefix' => ['!admin', '*'],
'controller' => '*',
'action' => '*',
],
'label' => 'CakeAdmin Panel',
'url' => '/admin'
]);
Explanation:
- goto_backend - The name of the item. Should be unique (because of overriding in the Configure-class).
- on - The on-key is used to validate if the item should be shown looking at the current request. See docs below.
- label - A string wich is the label of your item.
- url - A string or array to create the url. For all available options, see docs below., (*9)
Via the on-key you can validate if the item should be shown., (*10)
! before the used key (like 'prefix' => '!admin'), the current prefix should NOT be admin.'prefix' => 'admin') the current prefix has to be equal to admin.* (like 'prefix' => '*') the current prefix can be anything.'prefix' => ['!admin', '*'],
You can validate on plugin, prefix, controller, action and any other parameter you want to validate on. So this
means when you defined a parameter type in your routes, you can validate on type by using:, (*11)
Configure::write('AdminBar.custom_type', [
'on' => [
'controller' => '*',
'action' => '*',
'type' => 'specific'
],
]);
The url-key can be an string, or array to create an url. You can get parameters of the request using ::, (*12)
Configure::write('AdminBar.read_blog', [
'label' => 'Read Blog',
'url' => [
'prefix' => false,
'plugin' => 'Cms',
'controller' => 'Blogs',
'action' => 'view',
':pass.1'
]
]);
The :pass.1 is used to get a specific value of the request-parameters. When these are nested, use a . to go into them.
Looking back on our type-example, you could use this:, (*13)
Configure::write('AdminBar.custom_type', [
'url' => [
'prefix' => false,
'plugin' => 'Cms',
'controller' => 'Blogs',
'action' => 'view',
':type'
]
]);
If you need some help or got ideas for this plugin, feel free to chat at Gitter., (*14)
Pull Requests are always more than welcome!, (*15)
AdminBar plugin for CakeAdmin and CakePHP