Final Class Yiisoft\Hydrator\AttributeHandling\ResolverFactory\ContainerAttributeResolverFactory
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
A factory for attribute resolvers that are instantiable by a container.
Public Methods
Method Details
| public mixed __construct ( \ | ||
| $container | \ |
Container to get attributes' resolvers from. |
public function __construct(
private ContainerInterface $container,
) {}
| public mixed create ( Yiisoft\ | ||
| $attribute | Yiisoft\ |
|
| throws | \ |
|
|---|---|---|
public function create(DataAttributeInterface|ParameterAttributeInterface $attribute): mixed
{
$resolver = $attribute->getResolver();
if (!is_string($resolver)) {
return $resolver;
}
if (!$this->container->has($resolver)) {
throw new AttributeResolverNonInstantiableException(
sprintf(
'Class "%s" does not exist.',
$resolver,
),
);
}
return $this->container->get($resolver);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.