You are here

class LoaderChain in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/symfony/validator/Mapping/Loader/LoaderChain.php \Symfony\Component\Validator\Mapping\Loader\LoaderChain
  2. 8.0 vendor/symfony/serializer/Mapping/Loader/LoaderChain.php \Symfony\Component\Serializer\Mapping\Loader\LoaderChain
Same name and namespace in other branches
  1. 8 vendor/symfony/validator/Mapping/Loader/LoaderChain.php \Symfony\Component\Validator\Mapping\Loader\LoaderChain

Loads validation metadata from multiple {@link LoaderInterface} instances.

Pass the loaders when constructing the chain. Once {@link loadClassMetadata()} is called, that method will be called on all loaders in the chain.

@author Bernhard Schussek <bschussek@gmail.com>

Hierarchy

Expanded class hierarchy of LoaderChain

3 files declare their use of LoaderChain
LazyLoadingMetadataFactory.php in vendor/symfony/validator/Mapping/Factory/LazyLoadingMetadataFactory.php
LoaderChainTest.php in vendor/symfony/validator/Tests/Mapping/Loader/LoaderChainTest.php
ValidatorBuilder.php in vendor/symfony/validator/ValidatorBuilder.php

File

vendor/symfony/validator/Mapping/Loader/LoaderChain.php, line 26

Namespace

Symfony\Component\Validator\Mapping\Loader
View source
class LoaderChain implements LoaderInterface {

  /**
   * @var LoaderInterface[]
   */
  protected $loaders;

  /**
   * @param LoaderInterface[] $loaders The metadata loaders to use
   *
   * @throws MappingException If any of the loaders has an invalid type
   */
  public function __construct(array $loaders) {
    foreach ($loaders as $loader) {
      if (!$loader instanceof LoaderInterface) {
        throw new MappingException(sprintf('Class %s is expected to implement LoaderInterface', get_class($loader)));
      }
    }
    $this->loaders = $loaders;
  }

  /**
   * {@inheritdoc}
   */
  public function loadClassMetadata(ClassMetadata $metadata) {
    $success = false;
    foreach ($this->loaders as $loader) {
      $success = $loader
        ->loadClassMetadata($metadata) || $success;
    }
    return $success;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LoaderChain::$loaders protected property
LoaderChain::loadClassMetadata public function Loads validation metadata into a {@link ClassMetadata} instance. Overrides LoaderInterface::loadClassMetadata
LoaderChain::__construct public function 1