class EntityHandlerBase

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/EntityHandlerBase.php \Drupal\Core\Entity\EntityHandlerBase
  2. 10 core/lib/Drupal/Core/Entity/EntityHandlerBase.php \Drupal\Core\Entity\EntityHandlerBase
  3. 11.x core/lib/Drupal/Core/Entity/EntityHandlerBase.php \Drupal\Core\Entity\EntityHandlerBase

Provides a base class for entity handlers.

Hierarchy

Expanded class hierarchy of EntityHandlerBase

Related topics

1 file declares its use of EntityHandlerBase
EntityTypeManagerTest.php in core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php
Contains \Drupal\Tests\Core\Entity\EntityTypeManagerTest.

File

core/lib/Drupal/Core/Entity/EntityHandlerBase.php, line 14

Namespace

Drupal\Core\Entity
View source
abstract class EntityHandlerBase {
    use StringTranslationTrait;
    use DependencySerializationTrait;
    
    /**
     * The module handler to invoke hooks on.
     *
     * @var \Drupal\Core\Extension\ModuleHandlerInterface
     */
    protected $moduleHandler;
    
    /**
     * 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

Title Sort descending Modifiers Object type Summary Overrides
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
EntityHandlerBase::$moduleHandler protected property The module handler to invoke hooks on. 5
EntityHandlerBase::moduleHandler protected function Gets the module handler. 5
EntityHandlerBase::setModuleHandler public function Sets the module handler for this handler.
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.