You are here

protected function InvoiceRouteProvider::getInvoicePaymentFormRoute in Commerce Invoice 8.2

Gets the invoice payment-form route.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type.

Return value

\Symfony\Component\Routing\Route|null The generated route, if available.

1 call to InvoiceRouteProvider::getInvoicePaymentFormRoute()
InvoiceRouteProvider::getRoutes in src/InvoiceRouteProvider.php
Provides routes for entities.

File

src/InvoiceRouteProvider.php, line 82

Class

InvoiceRouteProvider
Provides routes for the Invoice entity.

Namespace

Drupal\commerce_invoice

Code

protected function getInvoicePaymentFormRoute(EntityTypeInterface $entity_type) {
  if ($entity_type
    ->hasLinkTemplate('payment-form')) {
    $route = new Route($entity_type
      ->getLinkTemplate('payment-form'));
    $entity_type_id = $entity_type
      ->id();
    $route
      ->setDefaults([
      '_form' => '\\Drupal\\commerce_invoice\\Form\\InvoicePaymentForm',
    ])
      ->setRequirement('_entity_access', "{$entity_type_id}.update")
      ->setOption('parameters', [
      $entity_type_id => [
        'type' => 'entity:' . $entity_type_id,
      ],
    ]);

    // Entity types with serial IDs can specify this in their route
    // requirements, improving the matching process.
    if ($this
      ->getEntityTypeIdKeyType($entity_type) === 'integer') {
      $route
        ->setRequirement($entity_type_id, '\\d+');
    }
    return $route;
  }
}