You are here

protected function ApplicableTransactionAccess::guessTransactionType in Transaction 8

Tries to determine the transaction type from request and route.

Parameters

\Symfony\Component\Routing\Route $route: The route to check access for.

\Symfony\Component\HttpFoundation\Request $request: The current request.

Return value

\Drupal\transaction\TransactionTypeInterface|null The transaction type, NULL if cannot be determined.

1 call to ApplicableTransactionAccess::guessTransactionType()
ApplicableTransactionAccess::access in src/Access/ApplicableTransactionAccess.php
Check if the transaction type is applicable to the content entity.

File

src/Access/ApplicableTransactionAccess.php, line 117

Class

ApplicableTransactionAccess
Checks access of applicable entity to transaction type.

Namespace

Drupal\transaction\Access

Code

protected function guessTransactionType(Route $route, Request $request) {
  $transaction_type = $request
    ->get('transaction_type');
  if (!$transaction_type instanceof TransactionTypeInterface) {
    $transaction_type_id = is_string($transaction_type) ? $transaction_type : $route
      ->getOption('_transaction_transaction_type_id');
    if (!empty($transaction_type_id)) {
      $transaction_type = $this->entityTypeManager
        ->getStorage('transaction_type')
        ->load($transaction_type_id);
    }
  }
  return $transaction_type;
}