Creating a new BridgeConX Plugin will involve you cloning this repository, and committing it to a new one with a proper name. All BridgeConX plugins must be named plugin-{PLUGIN_NAME}
.
- Edit the
name
property. Change "template" to your package name. - Update the
description
property. - Feel free to add yourself as an author.
- Update the namespace under
autoload.psr-4
to reflect your plugin's namespace. For example, if you are writing a YouTube plugin, you may namespace itBridgeConX\\YouTube\\
.
Rename the src/TemplateServiceProvider.php
to reflect your plugin's name. For example, if you are writing a YouTube plugin, you may call it src/YouTubeServiceProvider.php
.
Next, update the call to $this->plugin($name)
in the public function register()
to reflect your plugin's name. This MUST match the {PLUGIN_NAME}
used to define your composer package name.
A
BridgeConX\Exceptions\PluginNotRegistered
exception will be thrown if you do not call$this->plugin($name)
inside thePluginServiceProvider
'sregister()
method.
This will do four things:
- Register your routes file (located at
/src/routes.php
) with a route prefix of$name
. - Register your acl file (located at
/src/acl.php
), which will allow your plugin to register permissions into the Acl System. - Register a view namepsace called
bridgeconx-$name
to your views folder (located at/views
). - Call the
registerMenuItems()
andregisterWidgets()
methods at the appropriate time, once
See the (Laravel Documentation)[http://laravel.com/docs/master/routing] for information on routing. More information is in the example /src/routes.php
in this repository.
The $router
variable is available to you as an instance of the Laravel Router.
All of your routes will be prefixed with your plugin name. For example, if you are building a YouTube plugin named
youtube
, and you register a route forview
, the actual route will be/youtube/view
See the (BeatSwitch Lock Documentation)[https://github.com/BeatSwitch/lock] for information on Acl Permissions. More information is in the example /src/acl.php
in this repository.
The $lock
variable is available to you as an instance of the Acl repository.
In your controllers, you can check against permissions using the \BridgeConX\Plugin\Acl\Facades\Acl
facade, also available at \Acl
.
public function getIndex()
{
if(\Acl::can('view', 'youtube-videos'))
{
return view('bridgeconx-youtube::index');
}
}
In the registerMenuItems()
method, you can attach menu items to the master Menu Collection by calling $this->menu->add(MenuItem $menuItem)
.
MenuItems can be instantiated by using the static named, which has the following method signature:
public static function make($title, $url, $icon, $pattern = null)
The $icon
represents a font-awesome icon to render (without the fa
class, just fa-foo
) class name.
Likewise, in the registerWidgets()
method, you can attach widgets to the master Widget Collection by calling the $this->widget->add(Widget $widget)
.
Widgets can be instantiated by using the constructor, which has the following method signature:
public function __construct($title, $slug, $view, $getData = null);