public function MetatagDefaultsListBuilder::getLabelAndConfig in Metatag 8
Renders the Metatag defaults label plus its configuration.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The Metatag defaults entity.
Return value
array Render array for a table cell.
1 call to MetatagDefaultsListBuilder::getLabelAndConfig()
- MetatagDefaultsListBuilder::buildRow in src/
MetatagDefaultsListBuilder.php - Builds a row for an entity in the entity listing.
File
- src/
MetatagDefaultsListBuilder.php, line 103
Class
- MetatagDefaultsListBuilder
- Provides a listing of Metatag defaults entities.
Namespace
Drupal\metatagCode
public function getLabelAndConfig(EntityInterface $entity) {
$output = '<div>';
$prefix = '';
$inherits = '';
if ($entity
->id() != 'global') {
$prefix = '<div class="indentation"></div>';
$inherits .= 'Global';
}
if (strpos($entity
->id(), '__') !== FALSE) {
$prefix .= '<div class="indentation"></div>';
$entity_label = explode(': ', $entity
->get('label'));
$inherits .= ', ' . $entity_label[0];
}
if (!empty($inherits)) {
$output .= '<div><p>' . $this
->t('Inherits meta tags from: @inherits', [
'@inherits' => $inherits,
]) . '</p></div>';
}
$tags = $entity
->get('tags');
if (count($tags)) {
$output .= '<table>
<tbody>';
foreach ($tags as $tag_id => $tag_value) {
$output .= '<tr><td>' . $tag_id . ':</td><td>' . $tag_value . '</td></tr>';
}
$output .= '</tbody></table>';
}
$output .= '</div>';
return [
'data' => [
'#type' => 'details',
'#prefix' => $prefix,
'#title' => $entity
->label(),
'config' => [
'#markup' => $output,
],
],
];
}