You are here

class ScheduledTransitionRouteProvider in Scheduled Transitions 8

Same name and namespace in other branches
  1. 2.x src/Routing/ScheduledTransitionRouteProvider.php \Drupal\scheduled_transitions\Routing\ScheduledTransitionRouteProvider

Route provider for Scheduled Transition entities.

Hierarchy

Expanded class hierarchy of ScheduledTransitionRouteProvider

File

src/Routing/ScheduledTransitionRouteProvider.php, line 14

Namespace

Drupal\scheduled_transitions\Routing
View source
class ScheduledTransitionRouteProvider extends DefaultHtmlRouteProvider {

  /**
   * {@inheritdoc}
   */
  public function getRoutes(EntityTypeInterface $entity_type) {
    $collection = parent::getRoutes($entity_type);
    if ($route = $this
      ->getRescheduleFormRoute($entity_type)) {
      $collection
        ->add('entity.scheduled_transition.reschedule_form', $route);
    }
    return $collection;
  }

  /**
   * Gets the reschedule-form route.
   *
   * @param \Drupal\Core\Entity\EntityTypeInterface $entityType
   *   The entity type.
   *
   * @return \Symfony\Component\Routing\Route|null
   *   The generated route, if available.
   */
  protected function getRescheduleFormRoute(EntityTypeInterface $entityType) {

    // We check if it exists in case a third party has unset it.
    if ($entityType
      ->hasLinkTemplate('reschedule-form')) {
      $entityTypeId = $entityType
        ->id();
      $route = new Route($entityType
        ->getLinkTemplate('reschedule-form'));
      $route
        ->addDefaults([
        '_entity_form' => "{$entityTypeId}.reschedule",
        '_title' => 'Reschedule transition',
      ])
        ->setRequirement('_entity_access', "{$entityTypeId}.reschedule")
        ->setRequirement($entityTypeId, '\\d+')
        ->setOption('parameters', [
        $entityTypeId => [
          'type' => 'entity:' . $entityTypeId,
        ],
      ]);
      return $route;
    }
    return NULL;
  }

}

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::getDeleteFormRoute protected function Gets the delete-form route. 1
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
ScheduledTransitionRouteProvider::getRescheduleFormRoute protected function Gets the reschedule-form route.
ScheduledTransitionRouteProvider::getRoutes public function Provides routes for entities. Overrides DefaultHtmlRouteProvider::getRoutes