You are here

class TeamInvitationRouteProvider in Apigee Edge 8

Provides entity routes for team_invitation.

Hierarchy

Expanded class hierarchy of TeamInvitationRouteProvider

File

modules/apigee_edge_teams/src/Entity/TeamInvitationRouteProvider.php, line 30

Namespace

Drupal\apigee_edge_teams\Entity
View source
class TeamInvitationRouteProvider extends DefaultHtmlRouteProvider {
  use TeamRoutingHelperTrait;

  /**
   * {@inheritdoc}
   */
  public function getRoutes(EntityTypeInterface $entity_type) {
    $collection = parent::getRoutes($entity_type);
    $entity_type_id = $entity_type
      ->id();
    if ($delete_form = $this
      ->getDeleteFormRoute($entity_type)) {
      $collection
        ->add("entity.{$entity_type_id}.delete_form", $delete_form);
    }
    if ($accept_form = $this
      ->getAcceptFormRoute($entity_type)) {
      $collection
        ->add("entity.{$entity_type_id}.accept_form", $accept_form);
    }
    if ($decline_form = $this
      ->getDeclineFormRoute($entity_type)) {
      $collection
        ->add("entity.{$entity_type_id}.decline_form", $decline_form);
    }
    if ($resend_form = $this
      ->getResentFormRoute($entity_type)) {
      $collection
        ->add("entity.{$entity_type_id}.resend_form", $resend_form);
    }
    return $collection;
  }

  /**
   * Gets the delete-form route for team_invitation.
   *
   * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
   *   The entity type.
   *
   * @return \Symfony\Component\Routing\Route|null
   *   The generated route, if available.
   */
  protected function getDeleteFormRoute(EntityTypeInterface $entity_type) {
    if ($entity_type
      ->hasLinkTemplate('delete-form')) {
      $entity_type_id = $entity_type
        ->id();
      $route = new Route($entity_type
        ->getLinkTemplate('delete-form'));
      $route
        ->setDefault('_entity_form', "{$entity_type_id}.delete");
      $route
        ->setDefault('_title_callback', TeamInvitationTitleProvider::class . '::deleteTitle');
      $route
        ->setDefault('entity_type_id', $entity_type_id);
      $this
        ->ensureTeamParameter($route);
      $route
        ->setRequirement('_entity_access', "{$entity_type_id}.delete");
      return $route;
    }
  }

  /**
   * Gets the notify-form route for team_invitation.
   *
   * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
   *   The entity type.
   *
   * @return \Symfony\Component\Routing\Route|null
   *   The generated route, if available.
   */
  protected function getResentFormRoute(EntityTypeInterface $entity_type) {
    if ($entity_type
      ->hasLinkTemplate('resend-form')) {
      $entity_type_id = $entity_type
        ->id();
      $route = new Route($entity_type
        ->getLinkTemplate('resend-form'));
      $route
        ->setDefault('_entity_form', "{$entity_type_id}.resend");
      $route
        ->setDefault('_title_callback', TeamInvitationTitleProvider::class . '::resendTitle');
      $route
        ->setDefault('entity_type_id', $entity_type_id);
      $this
        ->ensureTeamParameter($route);
      $route
        ->setRequirement('_entity_access', "{$entity_type_id}.resend");
      return $route;
    }
  }

  /**
   * Gets the accept-form route for team_invitation.
   *
   * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
   *   The entity type.
   *
   * @return \Symfony\Component\Routing\Route|null
   *   The generated route, if available.
   */
  protected function getAcceptFormRoute(EntityTypeInterface $entity_type) {
    if ($entity_type
      ->hasLinkTemplate('accept-form')) {
      $entity_type_id = $entity_type
        ->id();
      $route = new Route($entity_type
        ->getLinkTemplate('accept-form'));
      $route
        ->setDefault('_entity_form', "{$entity_type_id}.accept");
      $route
        ->setDefault('_title_callback', TeamInvitationTitleProvider::class . '::acceptTitle');
      $route
        ->setDefault('entity_type_id', $entity_type_id);
      $this
        ->ensureTeamParameter($route);
      $route
        ->setRequirement('_entity_access', "{$entity_type_id}.accept");
      return $route;
    }
  }

  /**
   * Gets the decline-form route for team_invitation.
   *
   * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
   *   The entity type.
   *
   * @return \Symfony\Component\Routing\Route|null
   *   The generated route, if available.
   */
  protected function getDeclineFormRoute(EntityTypeInterface $entity_type) {
    if ($entity_type
      ->hasLinkTemplate('decline-form')) {
      $entity_type_id = $entity_type
        ->id();
      $route = new Route($entity_type
        ->getLinkTemplate('decline-form'));
      $route
        ->setDefault('_entity_form', "{$entity_type_id}.decline");
      $route
        ->setDefault('_title_callback', TeamInvitationTitleProvider::class . '::declineTitle');
      $route
        ->setDefault('entity_type_id', $entity_type_id);
      $this
        ->ensureTeamParameter($route);
      $route
        ->setRequirement('_entity_access', "{$entity_type_id}.decline");
      return $route;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DefaultHtmlRouteProvider::$entityFieldManager protected property The entity field manager.
DefaultHtmlRouteProvider::$entityTypeManager protected property The entity type manager.
DefaultHtmlRouteProvider::createInstance public static function Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface::createInstance 1
DefaultHtmlRouteProvider::getAddFormRoute protected function Gets the add-form route. 2
DefaultHtmlRouteProvider::getAddPageRoute protected function Gets the add page route. 2
DefaultHtmlRouteProvider::getCanonicalRoute protected function Gets the canonical route. 3
DefaultHtmlRouteProvider::getCollectionRoute protected function Gets the collection route. 2
DefaultHtmlRouteProvider::getDeleteMultipleFormRoute protected function Returns the delete multiple form route. 1
DefaultHtmlRouteProvider::getEditFormRoute protected function Gets the edit-form route. 1
DefaultHtmlRouteProvider::getEntityTypeIdKeyType protected function Gets the type of the ID key for a given entity type. 1
DefaultHtmlRouteProvider::__construct public function Constructs a new DefaultHtmlRouteProvider. 1
TeamInvitationRouteProvider::getAcceptFormRoute protected function Gets the accept-form route for team_invitation.
TeamInvitationRouteProvider::getDeclineFormRoute protected function Gets the decline-form route for team_invitation.
TeamInvitationRouteProvider::getDeleteFormRoute protected function Gets the delete-form route for team_invitation. Overrides DefaultHtmlRouteProvider::getDeleteFormRoute
TeamInvitationRouteProvider::getResentFormRoute protected function Gets the notify-form route for team_invitation.
TeamInvitationRouteProvider::getRoutes public function Provides routes for entities. Overrides DefaultHtmlRouteProvider::getRoutes
TeamRoutingHelperTrait::ensureTeamParameter private function If route contains the {team} parameter add required changes to the route.