private function LibraryItemFieldFormatter::renderAction in Library 8
Render the available actions.
Parameters
\Drupal\library\Entity\LibraryAction[] $actions: Actions to render.
int $item: Item by ID.
Return value
array Markup to render.
1 call to LibraryItemFieldFormatter::renderAction()
- LibraryItemFieldFormatter::getActions in src/
Plugin/ Field/ FieldFormatter/ LibraryItemFieldFormatter.php - Get actions.
File
- src/
Plugin/ Field/ FieldFormatter/ LibraryItemFieldFormatter.php, line 136
Class
- LibraryItemFieldFormatter
- Plugin implementation of the 'library_item_field_formatter' formatter.
Namespace
Drupal\library\Plugin\Field\FieldFormatterCode
private function renderAction(array $actions, $item) : array {
$output = [];
foreach ($actions as $action) {
$actionEntity = LibraryAction::load($action);
if ($actionEntity) {
$output[$actionEntity
->id()] = [
'title' => $actionEntity
->label(),
'url' => Url::fromRoute('library.single_transaction', [
'action' => $actionEntity
->id(),
'item' => $item,
]),
];
}
}
return $output;
}