public function EntityManager::getControllerClass

Returns an entity controller class.

Parameters

string $entity_type: The name of the entity type

string $controller_type: The name of the controller.

string|null $nested: (optional) If this controller definition is nested, the name of the key. Defaults to NULL.

Return value

string The class name for this controller instance.

5 calls to EntityManager::getControllerClass()
EntityManager::getAccessController in drupal/core/lib/Drupal/Core/Entity/EntityManager.php
Creates a new access controller instance.
EntityManager::getFormController in drupal/core/lib/Drupal/Core/Entity/EntityManager.php
Creates a new form controller instance.
EntityManager::getListController in drupal/core/lib/Drupal/Core/Entity/EntityManager.php
Creates a new list controller instance.
EntityManager::getRenderController in drupal/core/lib/Drupal/Core/Entity/EntityManager.php
Creates a new render controller instance.
EntityManager::getStorageController in drupal/core/lib/Drupal/Core/Entity/EntityManager.php
Creates a new storage controller instance.

File

drupal/core/lib/Drupal/Core/Entity/EntityManager.php, line 103
Contains \Drupal\Core\Entity\EntityManager.

Class

EntityManager
Manages entity type plugin definitions.

Namespace

Drupal\Core\Entity

Code

public function getControllerClass($entity_type, $controller_type, $nested = NULL) {
  $definition = $this
    ->getDefinition($entity_type);
  $definition = $definition['controllers'];
  if (empty($definition[$controller_type])) {
    throw new \InvalidArgumentException(sprintf('The entity (%s) did not specify a %s.', $entity_type, $controller_type));
  }
  $class = $definition[$controller_type];

  // Some class definitions can be nested.
  if (isset($nested)) {
    if (empty($class[$nested])) {
      throw new \InvalidArgumentException(sprintf("Missing '%s: %s' for entity '%s'", $controller_type, $nested, $entity_type));
    }
    $class = $class[$nested];
  }
  if (!class_exists($class)) {
    throw new \InvalidArgumentException(sprintf('Entity (%s) %s "%s" does not exist.', $entity_type, $controller_type, $class));
  }
  return $class;
}