Skip to content
Snippets Groups Projects

Resolve #3395960 "2.0.x add new"

Merged Thomas MUSA requested to merge 3395960-2.0.x-add-new into 2.0.x
24 files
+ 2685
57
Compare changes
  • Side-by-side
  • Inline
Files
24
<?php
namespace Drupal\ui_patterns_field_formatters\EventSubscriber;
use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
use Drupal\Core\Entity\EntityTypeEvent;
use Drupal\Core\Entity\EntityTypeEventSubscriberTrait;
use Drupal\Core\Entity\EntityTypeListenerInterface;
use Drupal\Core\Field\FieldStorageDefinitionEventSubscriberTrait;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Class UiPatternsFieldFormattersEntitySchemaSubscriber.
*
* allow to do things when the entity types change. For example, rebuild the
* source plugin definitions
*
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
* @SuppressWarnings(PHPMD.LongClassName)
* @SuppressWarnings(PHPMD.LongVariable)
*/
class UiPatternsFieldFormattersEntitySchemaSubscriber implements EntityTypeListenerInterface, EventSubscriberInterface {
use EntityTypeEventSubscriberTrait;
use FieldStorageDefinitionEventSubscriberTrait;
/**
* The ui_patterns source plugin manager
*
* @var \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface
*/
protected CachedDiscoveryInterface $uiPatternsSourcePluginManager;
/**
* Constructs a ViewsEntitySchemaSubscriber.
*
* @param \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface $ui_patterns_source_plugin_manager
* The entity type manager.
*/
public function __construct(CachedDiscoveryInterface $ui_patterns_source_plugin_manager) {
$this->uiPatternsSourcePluginManager = $ui_patterns_source_plugin_manager;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array {
return array_merge(
static::getEntityTypeEvents(),
static::getFieldStorageDefinitionEvents());
}
/**
* {@inheritdoc}
*/
public function onEntityTypeEvent(EntityTypeEvent $event, $event_name) {
$this->uiPatternsSourcePluginManager->clearCachedDefinitions();
}
}
Loading