You are here

class ContentTypesUpdatedSubscriber in Allow a content type only once (Only One) 8

Class ContentTypesUpdatedSubscriber.

Hierarchy

  • class \Drupal\onlyone_admin_toolbar\EventSubscriber\ContentTypesUpdatedSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of ContentTypesUpdatedSubscriber

1 string reference to 'ContentTypesUpdatedSubscriber'
onlyone_admin_toolbar.services.yml in modules/onlyone_admin_toolbar/onlyone_admin_toolbar.services.yml
modules/onlyone_admin_toolbar/onlyone_admin_toolbar.services.yml
1 service uses ContentTypesUpdatedSubscriber
onlyone.content_types.updated in modules/onlyone_admin_toolbar/onlyone_admin_toolbar.services.yml
Drupal\onlyone_admin_toolbar\EventSubscriber\ContentTypesUpdatedSubscriber

File

modules/onlyone_admin_toolbar/src/EventSubscriber/ContentTypesUpdatedSubscriber.php, line 12

Namespace

Drupal\onlyone_admin_toolbar\EventSubscriber
View source
class ContentTypesUpdatedSubscriber implements EventSubscriberInterface {

  /**
   * The route builder.
   *
   * @var \Drupal\Core\Routing\RouteBuilderInterface
   */
  protected $routeBuilder;

  /**
   * Constructor.
   *
   * @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder
   *   The route builder.
   */
  public function __construct(RouteBuilderInterface $route_builder) {
    $this->routeBuilder = $route_builder;
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events = [];
    $events[OnlyOneEvents::CONTENT_TYPES_UPDATED][] = [
      'rebuildMenu',
      0,
    ];
    return $events;
  }

  /**
   * Subscriber Callback for the event OnlyOneEvents::CONTENT_TYPES_UPDATED.
   */
  public function rebuildMenu() {
    $this->routeBuilder
      ->rebuild();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentTypesUpdatedSubscriber::$routeBuilder protected property The route builder.
ContentTypesUpdatedSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
ContentTypesUpdatedSubscriber::rebuildMenu public function Subscriber Callback for the event OnlyOneEvents::CONTENT_TYPES_UPDATED.
ContentTypesUpdatedSubscriber::__construct public function Constructor.