public function TransactionController::transactionCollectionTitle in Transaction 8
Provides a title callback for transaction collection pages.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request.
\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.
\Drupal\transaction\TransactionTypeInterface $transaction_type: (optional) The type of the transactions in the collection.
\Drupal\Core\Entity\ContentEntityInterface $target_entity: (optional) The target entity of the transactions in collection.
Return value
string The title for the entity collection view page.
1 string reference to 'TransactionController::transactionCollectionTitle'
File
- src/
Controller/ TransactionController.php, line 58
Class
- TransactionController
- Provides title callbacks for transaction entities.
Namespace
Drupal\transaction\ControllerCode
public function transactionCollectionTitle(Request $request, RouteMatchInterface $route_match, TransactionTypeInterface $transaction_type = NULL, ContentEntityInterface $target_entity = NULL) {
$route_options = $route_match
->getRouteObject()
->getOptions();
if (!$transaction_type && isset($route_options['_transaction_transaction_type_id'])) {
try {
$transaction_type = $this->entityTypeManager
->getStorage('transaction_type')
->load($route_options['_transaction_transaction_type_id']);
} catch (InvalidPluginDefinitionException $e) {
// Continue.
}
}
if (!$target_entity && isset($route_options['_transaction_target_entity_type_id'])) {
$target_entity = $request
->get($route_options['_transaction_target_entity_type_id']);
}
if ($target_entity) {
$title = $transaction_type ? $this
->t('%type transactions for %target', [
'%type' => $transaction_type
->label(),
'%target' => $target_entity
->label(),
]) : $this
->t('Transactions for %target', [
'%target' => $target_entity
->label(),
]);
}
else {
$title = $transaction_type ? $this
->t('%type transactions', [
'%type' => $transaction_type
->label(),
]) : $this
->t('Transactions');
}
return $title;
}