public function GroupContentEnablerManager::getHandler in Group 8
Returns a handler instance for the given plugin and handler.
Entity handlers are instantiated once per entity type and then cached in the entity type manager, and so subsequent calls to getHandler() for a particular entity type and handler type will return the same object. This means that properties on a handler may be used as a static cache, although as the handler is common to all entities of the same type, any data that is per-entity should be keyed by the entity ID.
Parameters
string $plugin_id: The plugin ID for this handler.
string $handler_type: The handler type to create an instance for.
Return value
object A handler instance.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
Overrides GroupContentEnablerManagerInterface::getHandler
2 calls to GroupContentEnablerManager::getHandler()
- GroupContentEnablerManager::getAccessControlHandler in src/
Plugin/ GroupContentEnablerManager.php - Creates a new access control handler instance.
- GroupContentEnablerManager::getPermissionProvider in src/
Plugin/ GroupContentEnablerManager.php - Creates a new permission provider instance.
File
- src/
Plugin/ GroupContentEnablerManager.php, line 135
Class
- GroupContentEnablerManager
- Manages GroupContentEnabler plugin implementations.
Namespace
Drupal\group\PluginCode
public function getHandler($plugin_id, $handler_type) {
if (!isset($this->handlers[$handler_type][$plugin_id])) {
$definition = $this
->getDefinition($plugin_id);
if (!isset($definition['handlers'][$handler_type])) {
throw new InvalidPluginDefinitionException($plugin_id, sprintf('The "%s" plugin did not specify a %s handler.', $plugin_id, $handler_type));
}
$this->handlers[$handler_type][$plugin_id] = $this
->createHandlerInstance($definition['handlers'][$handler_type], $plugin_id, $definition);
}
return $this->handlers[$handler_type][$plugin_id];
}