function ElementInfoManager::getIdFromClass

Get the plugin ID from the class.

Whenever possible, use the class type inference. Calling this method should not be necessary.

@internal

Parameters

string $class: The class of an element object.

Return value

?string The plugin ID or null if not found.

Overrides ElementInfoManagerInterface::getIdFromClass

2 calls to ElementInfoManager::getIdFromClass()
ElementInfoManager::fromClass in core/lib/Drupal/Core/Render/ElementInfoManager.php
Creates a render object based on the provided class and configuration.
ElementInfoManager::fromRenderable in core/lib/Drupal/Core/Render/ElementInfoManager.php
Creates a render object from a render array.

File

core/lib/Drupal/Core/Render/ElementInfoManager.php, line 256

Class

ElementInfoManager
Provides a plugin manager for element plugins.

Namespace

Drupal\Core\Render

Code

public function getIdFromClass(string $class) : ?string {
  $this->getDefinitions();
  return $this->reverseMapping[$class] ?? NULL;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.