PanelizerTerm.php in Panelizer 8.4
File
src/Plugin/PanelizerEntity/PanelizerTerm.php
View source
<?php
namespace Drupal\panelizer\Plugin\PanelizerEntity;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\panelizer\Plugin\PanelizerEntityBase;
use Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant;
class PanelizerTerm extends PanelizerEntityBase {
public function getDefaultDisplay(EntityViewDisplayInterface $display, $bundle, $view_mode) {
$panels_display = parent::getDefaultDisplay($display, $bundle, $view_mode)
->setPageTitle('[term:name]');
foreach ($panels_display
->getRegionAssignments() as $region => $blocks) {
foreach ($blocks as $block_id => $block) {
if ($block
->getPluginId() == 'entity_field:taxonomy_term:name') {
$panels_display
->removeBlock($block_id);
}
}
}
return $panels_display;
}
public function alterBuild(array &$build, EntityInterface $entity, PanelsDisplayVariant $panels_display, $view_mode) {
parent::alterBuild($build, $entity, $panels_display, $view_mode);
if ($entity
->id()) {
$build['#contextual_links']['taxonomy_term'] = [
'route_parameters' => [
'taxonomy_term' => $entity
->id(),
],
'metadata' => [
'changed' => $entity
->getChangedTime(),
],
];
}
}
}
Classes
Name |
Description |
PanelizerTerm |
Panelizer entity plugin for integrating with taxonomy terms. |