You are here

class ProductVariationRouteProvider in Commerce Core 8.2

Provides routes for the product variation entity.

Hierarchy

Expanded class hierarchy of ProductVariationRouteProvider

File

modules/product/src/ProductVariationRouteProvider.php, line 13

Namespace

Drupal\commerce_product
View source
class ProductVariationRouteProvider extends AdminHtmlRouteProvider {

  /**
   * {@inheritdoc}
   */
  protected function getAddFormRoute(EntityTypeInterface $entity_type) {

    // The add-form route has no bundle argument because the bundle is selected
    // via the product ($product_type->getVariationTypeId()).
    $route = new Route($entity_type
      ->getLinkTemplate('add-form'));
    $route
      ->setDefaults([
      '_entity_form' => 'commerce_product_variation.add',
      'entity_type_id' => 'commerce_product_variation',
      '_title_callback' => ProductVariationController::class . '::addTitle',
    ])
      ->setRequirement('_product_variation_create_access', 'TRUE')
      ->setOption('parameters', [
      'commerce_product' => [
        'type' => 'entity:commerce_product',
      ],
    ])
      ->setOption('_admin_route', TRUE);
    return $route;
  }

  /**
   * {@inheritdoc}
   */
  protected function getEditFormRoute(EntityTypeInterface $entity_type) {
    $route = parent::getEditFormRoute($entity_type);
    $route
      ->setDefault('_title_callback', ProductVariationController::class . '::editTitle');
    $route
      ->setOption('parameters', [
      'commerce_product' => [
        'type' => 'entity:commerce_product',
      ],
      'commerce_product_variation' => [
        'type' => 'entity:commerce_product_variation',
      ],
    ]);
    $route
      ->setOption('_admin_route', TRUE);
    return $route;
  }

  /**
   * {@inheritdoc}
   */
  protected function getDeleteFormRoute(EntityTypeInterface $entity_type) {
    $route = parent::getDeleteFormRoute($entity_type);
    $route
      ->setDefault('_title_callback', ProductVariationController::class . '::deleteTitle');
    $route
      ->setOption('parameters', [
      'commerce_product' => [
        'type' => 'entity:commerce_product',
      ],
      'commerce_product_variation' => [
        'type' => 'entity:commerce_product_variation',
      ],
    ]);
    $route
      ->setOption('_admin_route', TRUE);
    return $route;
  }

  /**
   * {@inheritdoc}
   */
  protected function getCollectionRoute(EntityTypeInterface $entity_type) {
    $route = new Route($entity_type
      ->getLinkTemplate('collection'));
    $route
      ->addDefaults([
      '_entity_list' => 'commerce_product_variation',
      '_title_callback' => ProductVariationController::class . '::collectionTitle',
    ])
      ->setRequirement('_product_variation_collection_access', 'TRUE')
      ->setOption('parameters', [
      'commerce_product' => [
        'type' => 'entity:commerce_product',
      ],
    ])
      ->setOption('_admin_route', TRUE);
    return $route;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AdminHtmlRouteProvider::getRoutes public function Provides routes for entities. Overrides DefaultHtmlRouteProvider::getRoutes
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::getAddPageRoute protected function Gets the add page route. 2
DefaultHtmlRouteProvider::getCanonicalRoute protected function Gets the canonical route. 3
DefaultHtmlRouteProvider::getDeleteMultipleFormRoute protected function Returns the delete multiple form route. 1
DefaultHtmlRouteProvider::getDuplicateFormRoute protected function Gets the duplicate-form route.
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
ProductVariationRouteProvider::getAddFormRoute protected function Gets the add-form route. Overrides DefaultHtmlRouteProvider::getAddFormRoute
ProductVariationRouteProvider::getCollectionRoute protected function Gets the collection route. Overrides DefaultHtmlRouteProvider::getCollectionRoute
ProductVariationRouteProvider::getDeleteFormRoute protected function Gets the delete-form route. Overrides DefaultHtmlRouteProvider::getDeleteFormRoute
ProductVariationRouteProvider::getEditFormRoute protected function Gets the edit-form route. Overrides DefaultHtmlRouteProvider::getEditFormRoute