function EntityForm::getCallableFromDefinition

Gets a callable from a string or array definition if possible.

Checks if the service container is available and uses the callable resolver service to get the callable from the definition. Otherwise, it returns the definition as is.

Parameters

string|array $definition: The callable definition.

Return value

callable|string|array The callable, or the original definition if it could not be resolved.

File

core/lib/Drupal/Core/Entity/EntityForm.php, line 329

Class

EntityForm
Base class for entity forms.

Namespace

Drupal\Core\Entity

Code

protected function getCallableFromDefinition(string|array $definition) : callable|string|array {
  if (\Drupal::hasService(CallableResolver::class)) {
    return \Drupal::service(CallableResolver::class)->getCallableFromDefinition($definition);
  }
  return $definition;
}

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