Class

Symfony\Component\Validator\Mapping\ClassMetadataFactory

class ClassMetadataFactory extends LazyLoadingMetadataFactory

Alias of {@link LazyLoadingMetadataFactory}.

Methods

__construct(LoaderInterface $loader = null, CacheInterface $cache = null)

Creates a new metadata factory.

from LazyLoadingMetadataFactory
MetadataInterface getMetadataFor(string|object $value)

Returns the metadata for the given class name or object.

from LazyLoadingMetadataFactory
Boolean hasMetadataFor(string|object $value)

Returns whether the factory is able to return metadata for the given class name or object.

from LazyLoadingMetadataFactory

Details

public __construct(LoaderInterface $loader = null, CacheInterface $cache = null)

Creates a new metadata factory.

Parameters

LoaderInterface $loader The loader for configuring new metadata
CacheInterface $cache The cache for persisting metadata between multiple PHP requests

public MetadataInterface getMetadataFor(string|object $value)

Returns the metadata for the given class name or object.

If the method was called with the same class name (or an object of that class) before, the same metadata instance is returned.

If the factory was configured with a cache, this method will first look for an existing metadata instance in the cache. If an existing instance is found, it will be returned without further ado.

Otherwise, a new metadata instance is created. If the factory was configured with a loader, the metadata is passed to the {@link LoaderInterface::loadClassMetadata()} method for further configuration. At last, the new object is returned.

Parameters

string|object $value A class name or an object

Return Value

MetadataInterface The metadata for the value

Exceptions

NoSuchMetadataException If no metadata exists for the given value

public Boolean hasMetadataFor(string|object $value)

Returns whether the factory is able to return metadata for the given class name or object.

Parameters

string|object $value A class name or an object

Return Value

Boolean Whether metadata can be returned for that class