class WishlistRouteProvider in Commerce Wishlist 8.3
Provides routes for the wishlist entity.
Hierarchy
- class \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider implements EntityHandlerInterface, EntityRouteProviderInterface
- class \Drupal\entity\Routing\DefaultHtmlRouteProvider
- class \Drupal\entity\Routing\AdminHtmlRouteProvider
- class \Drupal\commerce_wishlist\WishlistRouteProvider
- class \Drupal\entity\Routing\AdminHtmlRouteProvider
- class \Drupal\entity\Routing\DefaultHtmlRouteProvider
Expanded class hierarchy of WishlistRouteProvider
File
- src/
WishlistRouteProvider.php, line 14
Namespace
Drupal\commerce_wishlistView source
class WishlistRouteProvider extends AdminHtmlRouteProvider {
/**
* {@inheritdoc}
*/
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = parent::getRoutes($entity_type);
if ($share_form_route = $this
->getShareFormRoute($entity_type)) {
$collection
->add('entity.commerce_wishlist.share_form', $share_form_route);
}
if ($user_form_route = $this
->getUserFormRoute($entity_type)) {
$collection
->add('entity.commerce_wishlist.user_form', $user_form_route);
}
return $collection;
}
/**
* {@inheritdoc}
*/
protected function getCanonicalRoute(EntityTypeInterface $entity_type) {
$route = new Route('/wishlist/{code}');
$route
->addDefaults([
'_controller' => WishlistController::class . '::userForm',
'_title' => 'Wishlist',
])
->setRequirement('_access', 'TRUE');
return $route;
}
/**
* Gets the share-form route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getShareFormRoute(EntityTypeInterface $entity_type) {
$route = new Route($entity_type
->getLinkTemplate('share-form'));
$route
->addDefaults([
'_controller' => WishlistController::class . '::shareForm',
'_title' => 'Wishlist',
])
->setRequirement('_custom_access', WishlistUserAccessCheck::class . '::checkAccess')
->setOption('parameters', [
'user' => [
'type' => 'entity:user',
],
]);
return $route;
}
/**
* Gets the user-form route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getUserFormRoute(EntityTypeInterface $entity_type) {
$route = new Route($entity_type
->getLinkTemplate('user-form'));
$route
->addDefaults([
'_controller' => WishlistController::class . '::userForm',
'_title' => 'Wishlist',
])
->setRequirement('_custom_access', WishlistUserAccessCheck::class . '::checkAccess')
->setOption('parameters', [
'user' => [
'type' => 'entity:user',
],
]);
return $route;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultHtmlRouteProvider:: |
protected | property | The entity field manager. | |
DefaultHtmlRouteProvider:: |
protected | property | The entity type manager. | |
DefaultHtmlRouteProvider:: |
public static | function |
Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface:: |
1 |
DefaultHtmlRouteProvider:: |
protected | function | Gets the add-form route. | 2 |
DefaultHtmlRouteProvider:: |
protected | function | Gets the add page route. | 2 |
DefaultHtmlRouteProvider:: |
protected | function |
Gets the collection route. Overrides DefaultHtmlRouteProvider:: |
|
DefaultHtmlRouteProvider:: |
protected | function | Gets the delete-form route. | 1 |
DefaultHtmlRouteProvider:: |
protected | function | Returns the delete multiple form route. | 1 |
DefaultHtmlRouteProvider:: |
protected | function | Gets the duplicate-form route. | |
DefaultHtmlRouteProvider:: |
protected | function | Gets the edit-form route. | 1 |
DefaultHtmlRouteProvider:: |
protected | function | Gets the type of the ID key for a given entity type. | 1 |
DefaultHtmlRouteProvider:: |
public | function | Constructs a new DefaultHtmlRouteProvider. | 1 |
WishlistRouteProvider:: |
protected | function |
Gets the canonical route. Overrides DefaultHtmlRouteProvider:: |
|
WishlistRouteProvider:: |
public | function |
Provides routes for entities. Overrides AdminHtmlRouteProvider:: |
|
WishlistRouteProvider:: |
protected | function | Gets the share-form route. | |
WishlistRouteProvider:: |
protected | function | Gets the user-form route. |