You are here

abstract class GroupContentHandlerBase in Group 8

Provides a base class for group content handlers.

Hierarchy

Expanded class hierarchy of GroupContentHandlerBase

1 file declares its use of GroupContentHandlerBase
GroupContentEnablerManagerTest.php in tests/src/Unit/GroupContentEnablerManagerTest.php

File

src/Plugin/GroupContentHandlerBase.php, line 13

Namespace

Drupal\group\Plugin
View source
abstract class GroupContentHandlerBase implements GroupContentHandlerInterface {

  /**
   * The group content enabler definition.
   *
   * @var array
   */
  protected $definition;

  /**
   * The plugin ID as read from the definition.
   *
   * @var string
   */
  protected $pluginId;

  /**
   * The module handler to invoke hooks on.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * Constructs a GroupContentHandlerBase object.
   *
   * @param string $plugin_id
   *   The plugin ID.
   * @param array $definition
   *   The group content enabler definition.
   */
  public function __construct($plugin_id, array $definition) {
    $this->pluginId = $plugin_id;
    $this->definition = $definition;
  }

  /**
   * {@inheritdoc}
   */
  public static function createInstance(ContainerInterface $container, $plugin_id, array $definition) {
    return new static($plugin_id, $definition);
  }

  /**
   * Gets the module handler.
   *
   * @return \Drupal\Core\Extension\ModuleHandlerInterface
   *   The module handler.
   */
  protected function moduleHandler() {
    if (!$this->moduleHandler) {
      $this->moduleHandler = \Drupal::moduleHandler();
    }
    return $this->moduleHandler;
  }

  /**
   * Sets the module handler for this handler.
   *
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler.
   *
   * @return $this
   */
  public function setModuleHandler(ModuleHandlerInterface $module_handler) {
    $this->moduleHandler = $module_handler;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GroupContentHandlerBase::$definition protected property The group content enabler definition.
GroupContentHandlerBase::$moduleHandler protected property The module handler to invoke hooks on.
GroupContentHandlerBase::$pluginId protected property The plugin ID as read from the definition.
GroupContentHandlerBase::createInstance public static function Instantiates a new instance of this group content handler. Overrides GroupContentHandlerInterface::createInstance 2
GroupContentHandlerBase::moduleHandler protected function Gets the module handler.
GroupContentHandlerBase::setModuleHandler public function Sets the module handler for this handler.
GroupContentHandlerBase::__construct public function Constructs a GroupContentHandlerBase object.