PHP Class Neos\Flow\Core\ClassLoader

Show file Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Property Type Description
$availableProxyClasses array
$classesCache Neos\Cache\Frontend\PhpFrontend
$considerTestsNamespace boolean
$fallbackClassPaths array
$ignoredClassNames array
$nonExistentClasses array Usually these will be annotations that have no class.
$packageNamespaces array A list of namespaces this class loader is definitely responsible for.

Public Methods

Method Description
__construct ( ApplicationContext $context = null, array $defaultPackageEntries = [] )
createFallbackPathEntry ( string $path ) : void Adds an entry to the fallback path map. MappingType for this kind of paths is always PSR4 as no package namespace is used then.
initializeAvailableProxyClasses ( ApplicationContext $context = null ) : void Initialize available proxy classes from the cached list.
injectClassesCache ( PhpFrontend $classesCache ) : void Injects the cache for storing the renamed original classes
isAutoloadTypeWithPredictableClassPath ( string $mappingType ) : boolean Is the given mapping type predictable in terms of path to class name
loadClass ( string $className ) : boolean Loads php files containing classes or interfaces found in the classes directory of a package and specifically registered classes.
setConsiderTestsNamespace ( boolean $flag ) : void Sets the flag which enables or disables autoloading support for functional test files.
setPackages ( array $activePackages ) : void Sets the available packages

Protected Methods

Method Description
buildClassPathWithPsr0 ( array $classNameParts, string $classPath ) : string Try to build a path to a class according to PSR-0 rules.
buildClassPathWithPsr4 ( array $classNameParts, string $classPath, integer $packageNamespacePartCount ) : string Try to build a path to a class according to PSR-4 rules.
createNamespaceMapEntry ( string $namespace, string $classPath, string $mappingType = self::MAPPING_TYPE_PSR0 ) : void Add a namespace to class path mapping to the class loader for resolving classes.
loadClassFromPossiblePaths ( array $possiblePaths, array $namespaceParts, integer $packageNamespacePartCount ) : boolean Tries to load a class from a list of possible paths. This is needed because packages are not prefix-free; i.e.
removeNamespaceMapEntry ( string $namespace, string $classPath, string $mappingType = self::MAPPING_TYPE_PSR0 ) : void Tries to remove a possibly existing namespace to class path map entry.

Method Details

__construct() public method

public __construct ( ApplicationContext $context = null, array $defaultPackageEntries = [] )
$context ApplicationContext
$defaultPackageEntries array Adds default entries for packages that should be available for very early loading

buildClassPathWithPsr0() protected method

Try to build a path to a class according to PSR-0 rules.
protected buildClassPathWithPsr0 ( array $classNameParts, string $classPath ) : string
$classNameParts array Parts of the FQ classname.
$classPath string Already detected class path to a possible package.
return string

buildClassPathWithPsr4() protected method

Try to build a path to a class according to PSR-4 rules.
protected buildClassPathWithPsr4 ( array $classNameParts, string $classPath, integer $packageNamespacePartCount ) : string
$classNameParts array Parts of the FQ classname.
$classPath string Already detected class path to a possible package.
$packageNamespacePartCount integer Amount of parts of the className that is also part of the package namespace.
return string

createFallbackPathEntry() public method

Adds an entry to the fallback path map. MappingType for this kind of paths is always PSR4 as no package namespace is used then.
public createFallbackPathEntry ( string $path ) : void
$path string The fallback path to search in.
return void

createNamespaceMapEntry() protected method

Add a namespace to class path mapping to the class loader for resolving classes.
protected createNamespaceMapEntry ( string $namespace, string $classPath, string $mappingType = self::MAPPING_TYPE_PSR0 ) : void
$namespace string A namespace to map to a class path.
$classPath string The class path to be mapped.
$mappingType string The mapping type for this mapping entry. Currently one of self::MAPPING_TYPE_PSR0 or self::MAPPING_TYPE_PSR4 will work. Defaults to self::MAPPING_TYPE_PSR0
return void

initializeAvailableProxyClasses() public method

Initialize available proxy classes from the cached list.
public initializeAvailableProxyClasses ( ApplicationContext $context = null ) : void
$context ApplicationContext
return void

injectClassesCache() public method

Injects the cache for storing the renamed original classes
public injectClassesCache ( PhpFrontend $classesCache ) : void
$classesCache Neos\Cache\Frontend\PhpFrontend
return void

isAutoloadTypeWithPredictableClassPath() public static method

Is the given mapping type predictable in terms of path to class name
public static isAutoloadTypeWithPredictableClassPath ( string $mappingType ) : boolean
$mappingType string
return boolean

loadClass() public method

Loads php files containing classes or interfaces found in the classes directory of a package and specifically registered classes.
public loadClass ( string $className ) : boolean
$className string Name of the class/interface to load
return boolean

loadClassFromPossiblePaths() protected method

there may exist a package "Neos" and a package "Neos.NodeTypes" -- so a class Neos\NodeTypes\Foo must be first loaded (if it exists) from Neos.NodeTypes, falling back to Neos afterwards.
protected loadClassFromPossiblePaths ( array $possiblePaths, array $namespaceParts, integer $packageNamespacePartCount ) : boolean
$possiblePaths array
$namespaceParts array
$packageNamespacePartCount integer
return boolean

removeNamespaceMapEntry() protected method

Tries to remove a possibly existing namespace to class path map entry.
protected removeNamespaceMapEntry ( string $namespace, string $classPath, string $mappingType = self::MAPPING_TYPE_PSR0 ) : void
$namespace string A namespace mapped to a class path.
$classPath string The class path to be removed.
$mappingType string The mapping type for this mapping entry. Currently one of self::MAPPING_TYPE_PSR0 or self::MAPPING_TYPE_PSR4 will work. Defaults to self::MAPPING_TYPE_PSR0
return void

setConsiderTestsNamespace() public method

Sets the flag which enables or disables autoloading support for functional test files.
public setConsiderTestsNamespace ( boolean $flag ) : void
$flag boolean
return void

setPackages() public method

Sets the available packages
public setPackages ( array $activePackages ) : void
$activePackages array An array of \Neos\Flow\Package\Package objects
return void

Property Details

$availableProxyClasses protected property

protected array $availableProxyClasses
return array

$classesCache protected property

protected PhpFrontend,Neos\Cache\Frontend $classesCache
return Neos\Cache\Frontend\PhpFrontend

$considerTestsNamespace protected property

protected bool $considerTestsNamespace
return boolean

$fallbackClassPaths protected property

protected array $fallbackClassPaths
return array

$ignoredClassNames protected property

protected array $ignoredClassNames
return array

$nonExistentClasses protected property

Usually these will be annotations that have no class.
protected array $nonExistentClasses
return array

$packageNamespaces protected property

A list of namespaces this class loader is definitely responsible for.
protected array $packageNamespaces
return array