public function addMetadataDir($dir, $namespacePrefix = '')
    {
        if (! is_dir($dir)) {
            throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir));
        }

        if (isset($this->metadataDirs[$namespacePrefix])) {
            throw new InvalidArgumentException(sprintf('There is already a directory configured for the namespace prefix "%s". Please use replaceMetadataDir() to override directories.', $namespacePrefix));
        }

        $this->metadataDirs[$namespacePrefix] = $dir;

        return $this;
    }
public function addMetadataDir($dir, $namespacePrefix = '')
    {
        if (! is_dir($dir)) {
            throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir));
        }

        if (isset($this->metadataDirs[$namespacePrefix])) {
            throw new InvalidArgumentException(sprintf('There is already a directory configured for the namespace prefix "%s". Please use replaceMetadataDir() to override directories.', $namespacePrefix));
        }

        $this->metadataDirs[$namespacePrefix] = $dir;

        return $this;
    }
public function addMetadataDir ( $ dir , $ namespacePrefix = '' ) { if ( ! is_dir ( $ dir ) ) { throw new InvalidArgumentException ( sprintf ( 'The directory "%s" does not exist.' , $ dir ) ) ; } if ( isset ( $ this -> metadataDirs [ $ namespacePrefix ] ) ) { throw new InvalidArgumentException ( sprintf ( 'There is already a directory configured for the namespace prefix "%s". Please use replaceMetadataDir() to override directories.' , $ namespacePrefix ) ) ; } $ this -> metadataDirs [ $ namespacePrefix ] = $ dir ; return $ this ; }
Adds a directory where the serializer will look for class metadata.

The namespace prefix will make the names of the actual metadata files a bit shorter. For example, let's assume
that you have a directory where you only store metadata files for the ``MyApplication\Entity`` namespace.

If you use an empty prefix, your metadata files would need to look like:

``my-dir/MyApplication.Entity.SomeObject.yml``
``my-dir/MyApplication.Entity.OtherObject.xml``

If you use ``MyApplication\Entity`` as prefix, your metadata files would need to look like:

``my-dir/SomeObject.yml``
``my-dir/OtherObject.yml``

Please keep in mind that you currently may only have one directory per namespace prefix.

@param string $dir             The directory where metadata files are located.
@param string $namespacePrefix An optional prefix if you only store metadata for specific namespaces in this directory.

@return SerializerBuilder

@throws InvalidArgumentException When a directory does not exist
@throws InvalidArgumentException When a directory has already been registered
Adds a directory where the serializer will look for class metadata .