OrderRouteProvider.php in Commerce Core 8.2
File
modules/order/src/OrderRouteProvider.php
View source
<?php
namespace Drupal\commerce_order;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\entity\Routing\AdminHtmlRouteProvider;
use Symfony\Component\Routing\Route;
class OrderRouteProvider extends AdminHtmlRouteProvider {
protected function getCanonicalRoute(EntityTypeInterface $entity_type) {
$route = parent::getCanonicalRoute($entity_type);
$route
->setDefault('_entity_view', 'commerce_order.admin');
$route
->setOption('_admin_route', TRUE);
return $route;
}
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = parent::getRoutes($entity_type);
if ($resend_receipt_form_route = $this
->getResendReceiptFormRoute($entity_type)) {
$collection
->add("entity.commerce_order.resend_receipt_form", $resend_receipt_form_route);
}
$collection
->addRequirements([
'_permission' => 'access commerce administration pages',
]);
return $collection;
}
protected function getResendReceiptFormRoute(EntityTypeInterface $entity_type) {
$route = new Route($entity_type
->getLinkTemplate('resend-receipt-form'));
$route
->addDefaults([
'_entity_form' => 'commerce_order.resend-receipt',
'_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title',
])
->setRequirement('_entity_access', 'commerce_order.resend_receipt')
->setRequirement('commerce_order', '\\d+')
->setOption('parameters', [
'commerce_order' => [
'type' => 'entity:commerce_order',
],
])
->setOption('_admin_route', TRUE);
return $route;
}
}