Commit c50a87ce authored by Utz, Wolf-Peter's avatar Utz, Wolf-Peter
Browse files

Merge branch 'feature/menu' into 'master'

added menu subscriber for RicoCustomNavigation

See merge request shopware/plugins/RicoDynamicFAQ!13
parents 2dafff0c bacda602
<?php
/**
* @author: Alexander Wink <alexander.wink@riconet.de>
* @company: Hees riconet GmbH
* @package: RicoHistory
*/
namespace RicoDynamicFaq\Loader;
use Doctrine\ORM\EntityManager;
use RicoCustomNavigation\Services\NavigationTypeService;
use Shopware\Bundle\PluginInstallerBundle\Service\InstallerService;
/**
* Class RicoMenuConnector
*/
class RicoMenuLoader
{
/**
* Defines how the grid-entries are build and accessed
*/
const GRID_TYPE = [
'typeArgs' => [
'filterBy' => [],
'model' => '',
'displayField' => '',
'typeName' => 'FAQ',
'parameter' => [],
],
'dataArgs' => [
'type' => 'internal',
'linkTarget' => '',
'niceUrl' => false,
'controller' => 'Faq',
'action' => '',
'parameter' => [],
],
];
/**
* @var EntityManager
*/
private $manager;
/**
* @var NavigationTypeService
*/
private $typeService;
/**
* RicoMenuConnector constructor.
*
* @param EntityManager $manager
* @param InstallerService $pluginManager
*/
public function __construct(EntityManager $manager, NavigationTypeService $typeService)
{
$this->manager = $manager;
$this->typeService = $typeService;
}
public function registerEntry()
{
$this->typeService->registerType(self::GRID_TYPE['typeArgs'], self::GRID_TYPE['dataArgs']);
}
public function deRegisterEntry()
{
$this->typeService->deRegister(self::GRID_TYPE['typeArgs']['typeName']);
}
}
<?php
/**
* @author: Alexander Wink <alexander.wink@riconet.de>
* @company: Hees riconet GmbH
* @package: RicoGrids
*/
namespace RicoDynamicFaq\Subscriber;
use Enlight\Event\SubscriberInterface;
use RicoDynamicFaq\Loader\RicoMenuLoader;
use Shopware\Components\DependencyInjection\Container;
use Shopware\Components\Model\ModelManager;
/**
* Class NavigationSubscriber
*/
class NavigationSubscriber implements SubscriberInterface
{
/** @var Container */
private $container;
/** @var ModelManager */
private $modelManager;
/**
* NavigationSubscriber constructor.
*
* @param Container $container
* @param ModelManager $modelManager
*/
public function __construct(Container $container, ModelManager $modelManager)
{
$this->container = $container;
$this->modelManager = $modelManager;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
{
return [
'Enlight_Controller_Action_PostDispatch_Backend_RicoCustomNavigation' => 'registerMenu',
];
}
/**
* Registers the the grid-type for the custom navigation plugin
*/
public function registerMenu()
{
$menuRegistration = new RicoMenuLoader(
$this->modelManager,
$this->container->get('rico_custom_navigation.type_service')
);
$menuRegistration->registerEntry();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment