You are here

class ConfigSubscriber in CMS Content Sync 2.1.x

Same name and namespace in other branches
  1. 2.0.x src/EventSubscriber/ConfigSubscriber.php \Drupal\cms_content_sync\EventSubscriber\ConfigSubscriber

A subscriber triggering a config when certain configuration changes.

Hierarchy

  • class \Drupal\cms_content_sync\EventSubscriber\ConfigSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of ConfigSubscriber

File

src/EventSubscriber/ConfigSubscriber.php, line 16

Namespace

Drupal\cms_content_sync\EventSubscriber
View source
class ConfigSubscriber implements EventSubscriberInterface {

  /**
   * The config Factory.
   *
   * @var \Drupal\Core\Config\ConfigFactory
   */
  protected $config_factory;

  /**
   * The Core EntityTypeManager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManager
   */
  protected $entity_type_manager;

  /**
   * @param \Drupal\Core\Config\ConfigFactory $config_factory
   *   The config factory
   */
  public function __construct(ConfigFactory $config_factory, EntityTypeManagerInterface $entity_type_manager) {
    $this->config_factory = $config_factory;
    $this->entity_type_manager = $entity_type_manager;
  }

  /**
   * Delete unsed remote flows after config deletion.
   *
   * @param \Drupal\Core\Config\ConfigCrudEvent $event
   *   The Event to process
   */
  public function deleteUnusedFlows(ConfigCrudEvent $event) {
    if (str_contains($event
      ->getConfig()
      ->getName(), 'cms_content_sync.flow')) {
      Flow::resetFlowCache();
      SyncCoreFlowExport::deleteUnusedFlows();
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[ConfigEvents::DELETE][] = [
      'deleteUnusedFlows',
    ];
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigSubscriber::$config_factory protected property The config Factory.
ConfigSubscriber::$entity_type_manager protected property The Core EntityTypeManager.
ConfigSubscriber::deleteUnusedFlows public function Delete unsed remote flows after config deletion.
ConfigSubscriber::getSubscribedEvents public static function
ConfigSubscriber::__construct public function