function EntityDebugController::getEntityWithFieldDefinitions

Returns an entity with field definitions from the given route match.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match.

Return value

\Drupal\Core\Entity\EntityInterface|null The entity object with field definitions as determined from the passed-in route match.

2 calls to EntityDebugController::getEntityWithFieldDefinitions()
EntityDebugController::entityLoad in src/Controller/EntityDebugController.php
Returns the loaded structure of the current entity.
EntityDebugController::entityLoadWithReferences in src/Controller/EntityDebugController.php
Returns the loaded structure of the current entity with references.

File

src/Controller/EntityDebugController.php, line 220

Class

EntityDebugController
Controller for devel entity debug.

Namespace

Drupal\devel\Controller

Code

protected function getEntityWithFieldDefinitions(RouteMatchInterface $route_match) : ?EntityInterface {
    $entity = $this->getEntityFromRouteMatch($route_match);
    if (!$entity instanceof EntityInterface) {
        return NULL;
    }
    // Field definitions are lazy loaded and are populated only when needed.
    // By calling ::getFieldDefinitions() we are sure that field definitions
    // are populated and available in the dump output.
    // @see https://www.drupal.org/node/2311557
    if ($entity instanceof FieldableEntityInterface) {
        $entity->getFieldDefinitions();
    }
    return $entity;
}