You are here

class ContentLockRoutes in Content locking (anti-concurrent editing) 8

Same name and namespace in other branches
  1. 8.2 src/Routing/ContentLockRoutes.php \Drupal\content_lock\Routing\ContentLockRoutes

Class ContentLockRoutes.

@package Drupal\content_lock\Routing

Hierarchy

Expanded class hierarchy of ContentLockRoutes

File

src/Routing/ContentLockRoutes.php, line 16

Namespace

Drupal\content_lock\Routing
View source
class ContentLockRoutes implements ContainerInjectionInterface {
  protected $entityTypeManager;

  /**
   * {@inheritdoc}
   */
  public function __construct(EntityTypeManagerInterface $entityTypeManager) {
    $this->entityTypeManager = $entityTypeManager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('entity_type.manager'));
  }

  /**
   * {@inheritdoc}
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentLockRoutes::$entityTypeManager protected property
ContentLockRoutes::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
ContentLockRoutes::routes public function
ContentLockRoutes::__construct public function