public function TransactorHandler::composeDescription in Transaction 8
Compose a human readable description for the given transaction.
Parameters
\Drupal\transaction\TransactionInterface $transaction: The transaction to describe.
string $langcode: (optional) For which language the transaction description should be composed, defaults to the current content language.
Return value
\Drupal\Core\StringTranslation\TranslatableMarkup Translatable markup with the composed description.
Overrides TransactorHandlerInterface::composeDescription
File
- src/
TransactorHandler.php, line 213
Class
- TransactorHandler
- Transactor entity handler.
Namespace
Drupal\transactionCode
public function composeDescription(TransactionInterface $transaction, $langcode = NULL) {
if ($operation = $transaction
->getOperation()) {
// Description from operation template.
$token_options = [
'clear' => TRUE,
];
if ($langcode) {
$token_options['langcode'] = $langcode;
}
$target_entity = $transaction
->getTargetEntity();
$target_entity_type_id = $target_entity
->getEntityTypeId();
$token_data = [
'transaction' => $transaction,
TransactorHandler::getTokenContextFromEntityTypeId($target_entity_type_id) => $target_entity,
];
$description = PlainTextOutput::renderFromHtml($this->token
->replace($operation
->getDescription(), $token_data, $token_options));
}
else {
// Default description from the transactor.
$description = $transaction
->getType()
->getPlugin()
->getTransactionDescription($transaction, $langcode);
}
return $description;
}