Integration hub

Adding your own integeration hub page into Jadu CMS Continnum couldn't be easier as of Continuum #51 / 16.1.0.

Getting Started

We recommend you use composer to pull in your integration. All the code can be separated and bootstrapped into Jadu CMS Core. Here's a basic directory layout for your integration hub page:

Controllers
Views

And include some files within those directories:

Controllers/ManageController.php
Views/index.html.twig
ServiceLocator.php
MyCustomIntegration.php

As you can see, there are 4 files.

Controller

<?php

namespace MyNamespace\Controllers;

use Jadu\UI\Contollers\ControlCentre\Resource as ResourceController;

class ManageController extends ResourceController
{
    // code
}

View

Within your Views/index.html.twig, you can add your integration hub page. This may contain HTML, CSS and JavaScript.

<p>My custom integration hub page...<p>

Integration

<?php

namespace MyNamespace;

final class MyIntegration extends AbstractIntegration
{
    public function getTitle();
    public function getDescription();
    public function getImage();
    public function getUrl();
}

Service Location

Adding services to Jadu requires you to add an entry into the services.xml config, which points to a class that extends JaduFramework\Service\AbstractLocator. The AbstractLocator class requires you to implement init(), which runs when the service is invoked.

<?php

namespace MyNamespace;

use JaduFramework\Service\AbstractLocator;

final class ServiceLocator extends AbstractLocator 
{
    public function init();
}

Registering Routes

Routes within service locators can be registered during the ServiceLocator construction. We advise moving these into a separate method, for example boot. The locator has access to Jadu's ServiceLocator which provides the Jadu\Router instance, allowing you to add routes at run time.

<?php

namespace MyNamespace;

use JaduFramework\Service\AbstractLocation;
use Jadu\Service\Container as ServiceContainer;

final class ServiceLocator extends AbstractLocator
{
    /**
    * @var ServiceContainer
    */
    protected $serviceContainer;

    public function __construct(ServiceContainer $container)
    {
        parent::__construct($container;

        $this->boot();
    }

    private function boot()
    {
        $router = $this->serviceContainer->getRouter();

        $router->add(new \Jadu_Route('GET', '/jadu/integrations/my-integrations', 'MyNamespace\Controllers\ManageController::index');
    }
}

results matching ""

    No results matching ""