You are here

class MentionsDelete in Open Social 10.0.x

Same name and namespace in other branches
  1. 8.9 modules/custom/mentions/src/EventSubscriber/MentionsDelete.php \Drupal\mentions\EventSubscriber\MentionsDelete
  2. 8 modules/custom/mentions/src/EventSubscriber/MentionsDelete.php \Drupal\mentions\EventSubscriber\MentionsDelete
  3. 8.2 modules/custom/mentions/src/EventSubscriber/MentionsDelete.php \Drupal\mentions\EventSubscriber\MentionsDelete
  4. 8.3 modules/custom/mentions/src/EventSubscriber/MentionsDelete.php \Drupal\mentions\EventSubscriber\MentionsDelete
  5. 8.4 modules/custom/mentions/src/EventSubscriber/MentionsDelete.php \Drupal\mentions\EventSubscriber\MentionsDelete
  6. 8.5 modules/custom/mentions/src/EventSubscriber/MentionsDelete.php \Drupal\mentions\EventSubscriber\MentionsDelete
  7. 8.6 modules/custom/mentions/src/EventSubscriber/MentionsDelete.php \Drupal\mentions\EventSubscriber\MentionsDelete
  8. 8.7 modules/custom/mentions/src/EventSubscriber/MentionsDelete.php \Drupal\mentions\EventSubscriber\MentionsDelete
  9. 8.8 modules/custom/mentions/src/EventSubscriber/MentionsDelete.php \Drupal\mentions\EventSubscriber\MentionsDelete
  10. 10.3.x modules/custom/mentions/src/EventSubscriber/MentionsDelete.php \Drupal\mentions\EventSubscriber\MentionsDelete
  11. 10.1.x modules/custom/mentions/src/EventSubscriber/MentionsDelete.php \Drupal\mentions\EventSubscriber\MentionsDelete
  12. 10.2.x modules/custom/mentions/src/EventSubscriber/MentionsDelete.php \Drupal\mentions\EventSubscriber\MentionsDelete

MentionsDelete handles event 'mentions.delete'.

Hierarchy

  • class \Drupal\mentions\EventSubscriber\MentionsDelete implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of MentionsDelete

File

modules/custom/mentions/src/EventSubscriber/MentionsDelete.php, line 12

Namespace

Drupal\mentions\EventSubscriber
View source
class MentionsDelete implements EventSubscriberInterface {

  /**
   * The entity type manager interface.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactory
   */
  protected $configFactory;

  /**
   * MentionsDelete constructor.
   *
   * @param \Drupal\Core\Config\ConfigFactory $config_factory
   *   The config factory.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager interface.
   */
  public function __construct(ConfigFactory $config_factory, EntityTypeManagerInterface $entity_type_manager) {
    $this->configFactory = $config_factory;
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events = [];
    $events['mentions.delete'][] = [
      'onMentionsDelete',
      0,
    ];
    return $events;
  }

  /**
   * Event handler.
   */
  public function onMentionsDelete($event) {
    $config = $this->configFactory
      ->get('mentions.settings');
    $config_mentions_events = $config
      ->get('mentions_events');
    $action_id = $config_mentions_events['delete'];
    if (empty($action_id)) {
      return;
    }
    $entity_storage = $this->entityTypeManager
      ->getStorage('action');
    $action = $entity_storage
      ->load($action_id);
    if ($action === NULL) {
      return;
    }
    $action_plugin = $action
      ->getPlugin();
    if (!empty($action_plugin)) {
      $action_plugin
        ->execute(FALSE);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MentionsDelete::$configFactory protected property The config factory.
MentionsDelete::$entityTypeManager protected property The entity type manager interface.
MentionsDelete::getSubscribedEvents public static function
MentionsDelete::onMentionsDelete public function Event handler.
MentionsDelete::__construct public function MentionsDelete constructor.