1. Go to this page and download the library: Download wieni/wmentity_overview library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Drupal\wmentity_overview\Annotation\OverviewBuilder;
function yourmodule_entity_overview_alter(OverviewBuilder $definition, array &$overview)
{
if (!empty($overview['form'])) {
$overview['form']['#attributes']['class'][] = 'custom-entity-overview__form';
}
$overview['table']['#attributes']['class'][] = 'custom-entity-overview__table';
}
namespace Drupal\yourmodule\EventSubscriber;
use Drupal\wmentity_overview\Event\EntityOverviewAlterEvent;
use Drupal\wmentity_overview\WmEntityOverviewEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class EntityOverviewSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
$events[WmEntityOverviewEvents::ENTITY_OVERVIEW_ALTER][] = ['onAlter'];
return $events;
}
public function onAlter(EntityOverviewAlterEvent $event): void
{
$overview = &$event->getOverview();
if (!empty($overview['form'])) {
$overview['form']['#attributes']['class'][] = 'custom-entity-overview__form';
}
$overview['table']['#attributes']['class'][] = 'custom-entity-overview__table';
}
}
namespace Drupal\yourmodule\EventSubscriber;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\wmentity_overview\Event\EntityOverviewAlternativesAlterEvent;
use Drupal\wmentity_overview\OverviewBuilder\OverviewBuilderManager;
use Drupal\wmentity_overview\WmEntityOverviewEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class EntityOverviewAlternativesSubscriber implements EventSubscriberInterface
{
/** @var OverviewBuilderManager */
protected $overviewBuilders;
/** @var RouteMatchInterface */
protected $routeMatch;
public function __construct(
OverviewBuilderManager $overviewBuilders,
RouteMatchInterface $routeMatch
) {
$this->overviewBuilders = $overviewBuilders;
$this->routeMatch = $routeMatch;
}
public static function getSubscribedEvents()
{
$events[WmEntityOverviewEvents::ENTITY_OVERVIEW_ALTERNATIVES_ALTER][] = ['onTaxonomyAlternativesAlter'];
return $events;
}
/**
* Since taxonomy has a per-bundle overview, we get the bundle from
* the route parameters and use it to add more possible alternatives.
*/
public function onTaxonomyAlternativesAlter(EntityOverviewAlternativesAlterEvent $event): void
{
if (!$vocabulary = $this->routeMatch->getParameter('taxonomy_vocabulary')) {
return;
}
if ($event->getDefinition()->getEntityTypeId() !== 'taxonomy_term') {
return;
}
$filters = ['vid' => $vocabulary->id()];
$alternatives = array_merge(
$event->getAlternatives(),
$this->overviewBuilders->getAlternativesByFilters($event->getDefinition(), $filters)
);
$event->setAlternatives($alternatives);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.