public EntityTypeManager::createHandlerInstance($class, EntityTypeInterface $definition = NULL)
Creates new handler instance.
Usually \Drupal\Core\Entity\EntityManagerInterface::getHandler() is preferred since that method has additional checking that the class exists and has static caches.
Parameters
mixed $class: The handler class to instantiate.
\Drupal\Core\Entity\EntityTypeInterface $definition: The entity type definition.
Return value
object A handler instance.
Overrides EntityTypeManagerInterface::createHandlerInstance
File
- core/lib/Drupal/Core/Entity/EntityTypeManager.php, line 247
Class
- EntityTypeManager
- Manages entity type plugin definitions.
Namespace
Drupal\Core\Entity
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | public function createHandlerInstance( $class , EntityTypeInterface $definition = NULL) { if ( is_subclass_of ( $class , 'Drupal\Core\Entity\EntityHandlerInterface' )) { $handler = $class ::createInstance( $this ->container, $definition ); } else { $handler = new $class ( $definition ); } if (method_exists( $handler , 'setModuleHandler' )) { $handler ->setModuleHandler( $this ->moduleHandler); } if (method_exists( $handler , 'setStringTranslation' )) { $handler ->setStringTranslation( $this ->stringTranslation); } return $handler ; } |
Please login to continue.