Skip to content

Extensions # Embedded Administration

hertsch edited this page Aug 1, 2013 · 3 revisions

Often a Extension is split into parts:

  • the output or interaction over the front-end of the website
  • the administration and control of the application

For the front-end output you can use the kitCommands.

For the administration of your extension you should create protected routes which can directly accessed, but outside of the parent Content Management System. To enable the users of your extension an access directly from the back-end of the CMS, you can use the Embedded Administration.

Embedded Administration mean, that you provide a Admin-Tool in the back-end of the parent Content Management System. This is very easy to handle:

  • let the kitFramework install a Admin-Tool for your extension
  • use the class EmbeddedAdministration to create a bridge between the CMS and your extension.

First install the Admin-Tool.

In your Setup class add

use phpManufaktur\Basic\Control\CMS\InstallAdminTool;

In the exec() function of your Setup class add

$admin = new InstallAdminTool($this->app);
$admin->exec(THIRDPARTY_PATH.'/MyExtension/extension.json', '/myextension/cms');

The first parameter of the exec() function is the path to your extension.json, which contain all information needed by the class InstallAdminTool.

The second parameter is the route which will be used by the Admin-Tool, in the example '/myextension/cms'. Because this route will be called from the back-end of the CMS, the user is already authenticated by the CMS and the route does not need to start with '/admin'!

Now place a new controller in your bootstrap.include.php:

use phpManufaktur\Basic\Control\CMS\EmbeddedAdministration;

$app->get('/myextension/cms/{cms_information}', function ($cms_information) use ($app) {
    $administration = new EmbeddedAdministration($app);
    return $administration->route('/admin/myextension/about', $cms_information);
});

The route definition '/myextension/cms/{cms_information}' contains the additional variable {cms_information}, which will be set by the Admin-Tool and contains a Base64 encoded JSON string with additional information from the CMS.

The first parameter of the route() function is a protected route to the first dialog of your administration. This is only the entry point, all routes you are using there (i.e. with a toolbar) will be redirected to the Admin-Tool.

The class EmbeddedAdministration extract the information from the CMS and set the following Session variables:

CMS_LOCALE
CMS_USERNAME

You can access Session variables with

$this->app['session']->get('CMS_LOCALE');

In addition the the user will be authenticated for the kitFramework user management, therefore the user can access '/admin' routes inside and outside of the Content Management System.

At least the EmbeddedAdministration execute the the route '/admin/myextension/about' and attach the GET parameter usage. This parameter can have two values:

  • cms - in this case the route is called from the CMS
  • framework - in this case the route is called outside of the CMS

The usage parameter is useful i.e. to select different templates for the use inside the Admin-Tool a.s.o.

Clone this wiki locally