You are here

public function ContentLockRoutes::routes in Content locking (anti-concurrent editing) 8.2

Same name and namespace in other branches
  1. 8 src/Routing/ContentLockRoutes.php \Drupal\content_lock\Routing\ContentLockRoutes::routes()
1 string reference to 'ContentLockRoutes::routes'
content_lock.routing.yml in ./content_lock.routing.yml
content_lock.routing.yml

File

src/Routing/ContentLockRoutes.php, line 39

Class

ContentLockRoutes
Class ContentLockRoutes.

Namespace

Drupal\content_lock\Routing

Code

public function routes() {
  $routes = [];
  $definitions = $this->entityTypeManager
    ->getDefinitions();
  foreach ($definitions as $definition) {
    if ($definition instanceof ContentEntityTypeInterface) {
      $routes['content_lock.break_lock.' . $definition
        ->id()] = new Route('/admin/lock/break/' . $definition
        ->id() . '/{entity}/{langcode}/{form_op}', [
        '_form' => $definition
          ->getHandlerClass('break_lock_form'),
        '_title' => 'Break lock',
      ], [
        '_custom_access' => $definition
          ->getHandlerClass('break_lock_form') . '::access',
      ], [
        '_admin_route' => TRUE,
        'parameters' => [
          'entity' => [
            'type' => 'entity:' . $definition
              ->id(),
          ],
        ],
      ]);
      $routes['content_lock.create_lock.' . $definition
        ->id()] = new Route('/admin/lock/create/' . $definition
        ->id() . '/{entity}/{langcode}/{form_op}', [
        '_controller' => '\\Drupal\\content_lock\\Controller\\ContentLockController::createLockCall',
      ], [
        '_custom_access' => '\\Drupal\\content_lock\\Controller\\ContentLockController::access',
      ], [
        'parameters' => [
          'entity' => [
            'type' => 'entity:' . $definition
              ->id(),
          ],
        ],
      ]);
    }
  }
  return $routes;
}