MenuTreeResource.php in Colossal Menu 2.x
File
modules/colossal_menu_rest/src/Plugin/rest/resource/MenuTreeResource.php
View source
<?php
namespace Drupal\colossal_menu_rest\Plugin\rest\resource;
use Drupal\rest_menu_tree\Plugin\rest\resource\MenuTreeResource as BaseMenuTreeResource;
use Symfony\Component\DependencyInjection\ContainerInterface;
class MenuTreeResource extends BaseMenuTreeResource {
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->getParameter('serializer.formats'), $container
->get('logger.factory')
->get('rest'), $container
->get('colossal_menu.link_tree'), $container
->get('entity_type.manager'));
}
protected function getBaseRoute($canonical_path, $method) {
$route = parent::getBaseRoute($canonical_path, $method);
$parameters = $route
->getOption('parameters') ?: [];
$parameters['colossal_menu']['type'] = 'entity:colossal_menu';
$route
->setOption('parameters', $parameters);
return $route;
}
}