SymfonyFileLocator
in package
implements
FileLocator
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.
Table of Contents
Interfaces
- FileLocator
- Locates the file that contains the metadata information for a given class name.
Properties
- $fileExtension : string|null
- File extension that is searched for.
- $paths : array<int, string>
- The paths where to look for mapping files.
- $prefixes : array<string, string>
- A map of mapping directory path to namespace prefix used to expand class shortnames.
- $nsSeparator : string
- Represents PHP namespace delimiters when looking for files
Methods
- __construct() : mixed
- addNamespacePrefixes() : void
- Adds Namespace Prefixes.
- fileExists() : bool
- Checks if a file can be found for this class name.
- findMappingFile() : string
- Locates mapping file for the given class name.
- getAllClassNames() : array<int, string>
- Gets all class names that are found with this file locator.
- getFileExtension() : string|null
- Gets the file extension that mapping files are suffixed with.
- getNamespacePrefixes() : array<string|int, string>
- Gets Namespace Prefixes.
- getPaths() : array<int, string>
- Gets all the paths that this file locator looks for mapping files.
- setFileExtension() : void
- Sets the file extension used to look for mapping files under.
- realpath() : string
Properties
$fileExtension
File extension that is searched for.
protected
string|null
$fileExtension
$paths
The paths where to look for mapping files.
protected
array<int, string>
$paths
= []
$prefixes
A map of mapping directory path to namespace prefix used to expand class shortnames.
protected
array<string, string>
$prefixes
= []
$nsSeparator
Represents PHP namespace delimiters when looking for files
private
string
$nsSeparator
Methods
__construct()
public
__construct(array<string, string> $prefixes[, string $fileExtension = '' ][, string $nsSeparator = '.' ]) : mixed
Parameters
- $prefixes : array<string, string>
- $fileExtension : string = ''
- $nsSeparator : string = '.'
-
String which would be used when converting FQCN to filename and vice versa. Should not be empty
addNamespacePrefixes()
Adds Namespace Prefixes.
public
addNamespacePrefixes(array<string, string> $prefixes) : void
Parameters
- $prefixes : array<string, string>
fileExists()
Checks if a file can be found for this class name.
public
fileExists(string $className) : bool
Parameters
- $className : string
Return values
boolfindMappingFile()
Locates mapping file for the given class name.
public
findMappingFile(string $className) : string
Parameters
- $className : string
Return values
stringgetAllClassNames()
Gets all class names that are found with this file locator.
public
getAllClassNames([string|null $globalBasename = null ]) : array<int, string>
Parameters
- $globalBasename : string|null = null
-
Passed to allow excluding the basename.
Return values
array<int, string>getFileExtension()
Gets the file extension that mapping files are suffixed with.
public
getFileExtension() : string|null
Return values
string|nullgetNamespacePrefixes()
Gets Namespace Prefixes.
public
getNamespacePrefixes() : array<string|int, string>
Return values
array<string|int, string>getPaths()
Gets all the paths that this file locator looks for mapping files.
public
getPaths() : array<int, string>
Return values
array<int, string>setFileExtension()
Sets the file extension used to look for mapping files under.
public
setFileExtension(string $fileExtension) : void
Parameters
- $fileExtension : string
-
The file extension to set.
realpath()
private
realpath(string $path) : string
Parameters
- $path : string