EventGroupTypeController.php in Event 8
File
modules/event_group/src/Controller/EventGroupTypeController.php
View source
<?php
namespace Drupal\event_group\Controller;
use Drupal\group\Entity\Controller\GroupTypeController;
use Drupal\group\Entity\GroupTypeInterface;
use Drupal\group\Plugin\GroupContentEnablerInterface;
class EventGroupTypeController extends GroupTypeController {
public function content(GroupTypeInterface $group_type) {
$page = parent::content($group_type);
$plugin_id = 'event_group';
$installed = $this->pluginManager
->getInstalledIds($group_type);
$plugin = $this->pluginManager
->getDefinition($plugin_id);
if (in_array($plugin_id, $installed)) {
$plugin = $this->groupType
->getContentPlugin($plugin['id']);
}
$page['content'][$plugin_id] = $this
->buildEventRow($plugin);
return $page;
}
public function buildEventRow(GroupContentEnablerInterface $plugin) {
$status = $this
->t('Installed*');
$row = [
'info' => [
'#type' => 'inline_template',
'#template' => '<div class="description"><span class="label">{{ label }}</span>{% if description %}<br/>{{ description }}{% endif %}</div>',
'#context' => [
'label' => $plugin
->getLabel(),
],
],
'provider' => [
'#markup' => $this->moduleHandler
->getName($plugin
->getProvider()),
],
'entity_type_id' => [
'#markup' => $this->entityTypeManager
->getDefinition($plugin
->getEntityTypeId())
->getLabel(),
],
'status' => [
'#markup' => $status,
],
'operations' => $this
->buildOperations($plugin),
];
if (!system_admin_compact_mode()) {
$row['info']['#context']['description'] = $plugin
->getDescription();
}
return $row;
}
}
Classes
Name |
Description |
EventGroupTypeController |
Overrides the Group Content page to show that events are always installed.
Yes, this code is all so that an Asterisk (*) shows up for event group types. |