You are here

class SubscriptionRouteProvider in Commerce Recurring Framework 8

Provides routes for the Subscription entity.

Hierarchy

Expanded class hierarchy of SubscriptionRouteProvider

File

src/SubscriptionRouteProvider.php, line 12

Namespace

Drupal\commerce_recurring
View source
class SubscriptionRouteProvider extends DefaultHtmlRouteProvider {

  /**
   * {@inheritdoc}
   */
  public function getRoutes(EntityTypeInterface $entity_type) {
    $collection = parent::getRoutes($entity_type);
    if ($cancel_form_route = $this
      ->getCancelFormRoute($entity_type)) {
      $collection
        ->add('entity.commerce_subscription.cancel_form', $cancel_form_route);
    }
    if ($customer_view_route = $this
      ->getCustomerViewRoute($entity_type)) {
      $collection
        ->add('entity.commerce_subscription.customer_view', $customer_view_route);
    }
    if ($customer_edit_form_route = $this
      ->getCustomerEditFormRoute($entity_type)) {
      $collection
        ->add('entity.commerce_subscription.customer_edit_form', $customer_edit_form_route);
    }
    return $collection;
  }

  /**
   * Gets the cancel-form route.
   *
   * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
   *   The entity type.
   *
   * @return \Symfony\Component\Routing\Route
   *   The generated route.
   */
  protected function getCancelFormRoute(EntityTypeInterface $entity_type) {
    $route = new Route($entity_type
      ->getLinkTemplate('cancel-form'));
    $route
      ->addDefaults([
      '_entity_form' => 'commerce_subscription.cancel',
      '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title',
    ])
      ->setRequirement('_entity_access', 'commerce_subscription.cancel')
      ->setRequirement('commerce_subscription', '\\d+')
      ->setOption('parameters', [
      'commerce_subscription' => [
        'type' => 'entity:commerce_subscription',
      ],
    ]);
    return $route;
  }

  /**
   * Gets the customer-edit-form route.
   *
   * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
   *   The entity type.
   *
   * @return \Symfony\Component\Routing\Route
   *   The generated route.
   */
  protected function getCustomerEditFormRoute(EntityTypeInterface $entity_type) {
    $route = new Route($entity_type
      ->getLinkTemplate('customer-edit-form'));
    $route
      ->addDefaults([
      '_entity_form' => 'commerce_subscription.customer',
      '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title',
    ])
      ->setRequirement('_entity_access', 'commerce_subscription.update')
      ->setRequirement('commerce_subscription', '\\d+')
      ->setOption('parameters', [
      'user' => [
        'type' => 'entity:user',
      ],
      'commerce_subscription' => [
        'type' => 'entity:commerce_subscription',
      ],
    ]);
    return $route;
  }

  /**
   * Gets the customer-view route.
   *
   * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
   *   The entity type.
   *
   * @return \Symfony\Component\Routing\Route
   *   The generated route.
   */
  protected function getCustomerViewRoute(EntityTypeInterface $entity_type) {
    $route = new Route($entity_type
      ->getLinkTemplate('customer-view'));
    $route
      ->addDefaults([
      '_entity_view' => 'commerce_subscription.customer',
      '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title',
    ])
      ->setRequirement('_entity_access', 'commerce_subscription.view')
      ->setRequirement('commerce_subscription', '\\d+')
      ->setOption('parameters', [
      'user' => [
        'type' => 'entity:user',
      ],
      'commerce_subscription' => [
        'type' => 'entity:commerce_subscription',
      ],
    ]);
    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. Overrides DefaultHtmlRouteProvider::getCollectionRoute
DefaultHtmlRouteProvider::getDeleteFormRoute protected function Gets the delete-form route. 1
DefaultHtmlRouteProvider::getDeleteMultipleFormRoute protected function Returns the delete multiple form route. 1
DefaultHtmlRouteProvider::getDuplicateFormRoute protected function Gets the duplicate-form route.
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
SubscriptionRouteProvider::getCancelFormRoute protected function Gets the cancel-form route.
SubscriptionRouteProvider::getCustomerEditFormRoute protected function Gets the customer-edit-form route.
SubscriptionRouteProvider::getCustomerViewRoute protected function Gets the customer-view route.
SubscriptionRouteProvider::getRoutes public function Provides routes for entities. Overrides DefaultHtmlRouteProvider::getRoutes