You are here

class Routes in Entity Share 8

Same name and namespace in other branches
  1. 8.3 modules/entity_share_server/src/Routing/Routes.php \Drupal\entity_share_server\Routing\Routes
  2. 8.2 modules/entity_share_server/src/Routing/Routes.php \Drupal\entity_share_server\Routing\Routes

Defines dynamic routes.

@internal

Hierarchy

Expanded class hierarchy of Routes

File

modules/entity_share_server/src/Routing/Routes.php, line 17

Namespace

Drupal\entity_share_server\Routing
View source
class Routes implements ContainerInjectionInterface {

  /**
   * The authentication collector.
   *
   * @var \Drupal\Core\Authentication\AuthenticationCollectorInterface
   */
  protected $authCollector;

  /**
   * List of providers.
   *
   * @var string[]
   */
  protected $providerIds;

  /**
   * Instantiates a Routes object.
   *
   * @param \Drupal\Core\Authentication\AuthenticationCollectorInterface $auth_collector
   *   The authentication provider collector.
   */
  public function __construct(AuthenticationCollectorInterface $auth_collector) {
    $this->authCollector = $auth_collector;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {

    /* @var \Drupal\Core\Authentication\AuthenticationCollectorInterface $auth_collector */
    $auth_collector = $container
      ->get('authentication_collector');
    return new static($auth_collector);
  }

  /**
   * Provides the entry point route.
   */
  public function entryPoint() {
    $collection = new RouteCollection();
    $route_collection = (new Route('/entity_share', [
      RouteObjectInterface::CONTROLLER_NAME => '\\Drupal\\entity_share_server\\Controller\\EntryPoint::index',
    ]))
      ->setRequirement('_permission', 'entity_share_server_access_channels')
      ->setMethods([
      'GET',
    ]);
    $route_collection
      ->addOptions([
      '_auth' => $this
        ->authProviderList(),
    ]);
    $collection
      ->add('entity_share_server.resource_list', $route_collection);
    return $collection;
  }

  /**
   * Build a list of authentication provider ids.
   *
   * @return string[]
   *   The list of IDs.
   */
  protected function authProviderList() {
    if (isset($this->providerIds)) {
      return $this->providerIds;
    }
    $this->providerIds = array_keys($this->authCollector
      ->getSortedProviders());
    return $this->providerIds;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Routes::$authCollector protected property The authentication collector.
Routes::$providerIds protected property List of providers.
Routes::authProviderList protected function Build a list of authentication provider ids.
Routes::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
Routes::entryPoint public function Provides the entry point route.
Routes::__construct public function Instantiates a Routes object.