class SymfonyFileLocator implements FileLocator (View source)

The Symfony File Locator makes a simplifying assumptions compared to the DefaultFileLocator. By assuming paths only contain entities of a certain namespace the mapping files consists of the short classname only.

Properties

protected array $paths The paths where to look for mapping files.
protected array $prefixes A map of mapping directory path to namespace prefix used to expand class shortnames.
protected string|null $fileExtension File extension that is searched for.

Methods

__construct(array $prefixes, string|null $fileExtension = null, string $nsSeparator = '.')

Constructor.

void
addNamespacePrefixes(array $prefixes)

Adds Namespace Prefixes.

array
getNamespacePrefixes()

Gets Namespace Prefixes.

array
getPaths()

Gets all the paths that this file locator looks for mapping files.

string
getFileExtension()

Gets the file extension that mapping files are suffixed with.

void
setFileExtension(string $fileExtension)

Sets the file extension used to look for mapping files under.

bool
fileExists(string $className)

Checks if a file can be found for this class name.

array
getAllClassNames(string $globalBasename = null)

Gets all class names that are found with this file locator.

string
findMappingFile(string $className)

Locates mapping file for the given class name.

Details

__construct(array $prefixes, string|null $fileExtension = null, string $nsSeparator = '.')

Constructor.

Parameters

array $prefixes
string|null $fileExtension
string $nsSeparator String which would be used when converting FQCN to filename and vice versa. Should not be empty

void addNamespacePrefixes(array $prefixes)

Adds Namespace Prefixes.

Parameters

array $prefixes

Return Value

void

array getNamespacePrefixes()

Gets Namespace Prefixes.

Return Value

array

array getPaths()

Gets all the paths that this file locator looks for mapping files.

Return Value

array

string getFileExtension()

Gets the file extension that mapping files are suffixed with.

Return Value

string

void setFileExtension(string $fileExtension)

Sets the file extension used to look for mapping files under.

Parameters

string $fileExtension The file extension to set.

Return Value

void

bool fileExists(string $className)

Checks if a file can be found for this class name.

Parameters

string $className

Return Value

bool

array getAllClassNames(string $globalBasename = null)

Gets all class names that are found with this file locator.

Parameters

string $globalBasename Passed to allow excluding the basename.

Return Value

array

string findMappingFile(string $className)

Locates mapping file for the given class name.

Parameters

string $className

Return Value

string