public function getSchemaByType($type)
{
is_string($type) === true ?: Exceptions::throwInvalidArgument('type', $type);
if ($this->hasCreatedProvider($type) === true) {
return $this->getCreatedProvider($type);
}
if ($this->hasProviderMapping($type) === false) {
throw new InvalidArgumentException(T::t('Schema is not registered for type \'%s\'.', [$type]));
}
$classNameOrClosure = $this->getProviderMapping($type);
if ($classNameOrClosure instanceof Closure) {
$schema = $this->createSchemaFromClosure($classNameOrClosure);
} else {
$schema = $this->createSchemaFromClassName($classNameOrClosure);
}
$this->setCreatedProvider($type, $schema);
/** @var SchemaProviderInterface $schema */
$this->setResourceToJsonTypeMapping($schema->getResourceType(), $type);
return $schema;
}