You are here

public function JsonapiResourceClassResolver::getInstanceFromDefinition in JSON:API Resources 8

Returns a class instance with a given class definition.

In contrast to controllers you don't specify a method.

Parameters

string $definition: A class name or service name.

Return value

object The instance of the class.

Throws

\InvalidArgumentException If $class is not a valid service identifier and the class does not exist.

Overrides ClassResolver::getInstanceFromDefinition

File

src/Unstable/DependencyInjection/JsonapiResourceClassResolver.php, line 26

Class

JsonapiResourceClassResolver
Injects JSON:API resource dependencies that are internal to this module.

Namespace

Drupal\jsonapi_resources\Unstable\DependencyInjection

Code

public function getInstanceFromDefinition($definition) {
  $instance = parent::getInstanceFromDefinition($definition);
  if ($instance instanceof ResourceBase) {
    $this
      ->injectResourceDependencies($instance);
  }
  return $instance;
}