ConfigPagesRoutes.php in Config Pages 8
File
src/Routing/ConfigPagesRoutes.php
View source
<?php
namespace Drupal\config_pages\Routing;
use Drupal\config_pages\Entity\ConfigPagesType;
use Symfony\Component\Routing\Route;
class ConfigPagesRoutes {
public function routes() {
$routes = [];
$types = ConfigPagesType::loadMultiple();
foreach ($types as $cp_type) {
$bundle = $cp_type
->id();
$label = $cp_type
->get('label');
$menu = $cp_type
->get('menu');
$path = isset($menu['path']) ? $menu['path'] : '';
if (!$path) {
continue;
}
$routes['config_pages.' . $bundle] = new Route($path, [
'_controller' => '\\Drupal\\config_pages\\Controller\\ConfigPagesController::classInit',
'_title' => "Edit config page {$label}",
'config_pages_type' => $bundle,
], [
'_permission' => 'edit config_pages entity',
], [
'_admin_route' => TRUE,
]);
}
return $routes;
}
}