Mercurial > hg > isophonics-drupal-site
annotate core/lib/Drupal/Core/Entity/EntityHandlerBase.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\Core\Entity; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\Core\DependencyInjection\DependencySerializationTrait; |
Chris@0 | 6 use Drupal\Core\Extension\ModuleHandlerInterface; |
Chris@0 | 7 use Drupal\Core\StringTranslation\StringTranslationTrait; |
Chris@0 | 8 |
Chris@0 | 9 /** |
Chris@0 | 10 * Provides a base class for entity handlers. |
Chris@0 | 11 * |
Chris@0 | 12 * @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0. |
Chris@0 | 13 * Implement the container injection pattern of |
Chris@0 | 14 * \Drupal\Core\Entity\EntityHandlerInterface::createInstance() to obtain the |
Chris@0 | 15 * module handler service for your class. |
Chris@0 | 16 * |
Chris@0 | 17 * @ingroup entity_api |
Chris@0 | 18 */ |
Chris@0 | 19 abstract class EntityHandlerBase { |
Chris@0 | 20 use StringTranslationTrait; |
Chris@0 | 21 use DependencySerializationTrait; |
Chris@0 | 22 |
Chris@0 | 23 /** |
Chris@0 | 24 * The module handler to invoke hooks on. |
Chris@0 | 25 * |
Chris@0 | 26 * @var \Drupal\Core\Extension\ModuleHandlerInterface |
Chris@0 | 27 */ |
Chris@0 | 28 protected $moduleHandler; |
Chris@0 | 29 |
Chris@0 | 30 /** |
Chris@0 | 31 * Gets the module handler. |
Chris@0 | 32 * |
Chris@0 | 33 * @return \Drupal\Core\Extension\ModuleHandlerInterface |
Chris@0 | 34 * The module handler. |
Chris@0 | 35 */ |
Chris@0 | 36 protected function moduleHandler() { |
Chris@0 | 37 if (!$this->moduleHandler) { |
Chris@0 | 38 $this->moduleHandler = \Drupal::moduleHandler(); |
Chris@0 | 39 } |
Chris@0 | 40 return $this->moduleHandler; |
Chris@0 | 41 } |
Chris@0 | 42 |
Chris@0 | 43 /** |
Chris@0 | 44 * Sets the module handler for this handler. |
Chris@0 | 45 * |
Chris@0 | 46 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler |
Chris@0 | 47 * The module handler. |
Chris@0 | 48 * |
Chris@0 | 49 * @return $this |
Chris@0 | 50 */ |
Chris@0 | 51 public function setModuleHandler(ModuleHandlerInterface $module_handler) { |
Chris@0 | 52 $this->moduleHandler = $module_handler; |
Chris@0 | 53 return $this; |
Chris@0 | 54 } |
Chris@0 | 55 |
Chris@0 | 56 } |