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 string[] $paths The paths where to look for mapping files.
protected string[] $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 = '.')

No description

void
addNamespacePrefixes(array $prefixes)

Adds Namespace Prefixes.

string[]
getNamespacePrefixes()

Gets Namespace Prefixes.

string[]
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.

string[]
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 = '.')

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

string[] getNamespacePrefixes()

Gets Namespace Prefixes.

Return Value

string[]

string[] getPaths()

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

Return Value

string[]

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

string[] 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

string[]

string findMappingFile(string $className)

Locates mapping file for the given class name.

Parameters

string $className

Return Value

string