You are here

public function OnlyOneRoutes::routes in Allow a content type only once (Only One) 8

1 string reference to 'OnlyOneRoutes::routes'
onlyone.routing.yml in ./onlyone.routing.yml
onlyone.routing.yml

File

src/Routing/OnlyOneRoutes.php, line 44

Class

OnlyOneRoutes
Defines dynamic routes.

Namespace

Drupal\onlyone\Routing

Code

public function routes() {
  $routes = [];

  // Checking if we need to show the route.
  if ($this->configFactory
    ->get('onlyone.settings')
    ->get('onlyone_new_menu_entry')) {

    // Defining the route.
    $routes['onlyone.add_page'] = new Route('/onlyone/add', [
      '_controller' => '\\Drupal\\onlyone\\Controller\\OnlyOneController::addPage',
      '_title' => 'Add content (Only One)',
    ], [
      '_node_add_access' => 'node',
    ], [
      '_node_operation_route' => TRUE,
    ]);
  }
  return $routes;
}