PHP 클래스 Contao\ClassLoader

The class stores namespaces and classes and automatically loads the class files upon their first usage. It uses a mapper array to support complex nesting and arbitrary subfolders to store the class files in. Usage: ClassLoader::addNamespace('Custom'); ClassLoader::addClass('Custom\\Calendar', 'calendar/Calendar.php');
사용 중단: Deprecated since Contao 4.2, to be removed in Contao 5. Use the Composer autoloader instead.
파일 보기 프로젝트 열기: contao/core-bundle 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$classes array Known classes
$namespaces array Known namespaces

공개 메소드들

메소드 설명
addClass ( string $class, string $file ) Add a new class with its file path
addClasses ( array $classes ) Add multiple new classes with their file paths
addNamespace ( string $name ) Add a new namespace
addNamespaces ( array $names ) Add multiple new namespaces
getClasses ( ) : array Return the classes as array.
getNamespaces ( ) : array Return the namespaces as array
load ( string $class ) Autoload a class and create an alias in the global namespace
register ( ) Register the autoloader
scanAndRegister ( ) Scan the module directories for config/autoload.php files and then register the autoloader on the SPL stack

보호된 메소드들

메소드 설명
findClass ( string $class ) : string | null Search the namespaces for a matching entry

메소드 상세

addClass() 공개 정적인 메소드

Add a new class with its file path
public static addClass ( string $class, string $file )
$class string The class name
$file string The path to the class file

addClasses() 공개 정적인 메소드

Add multiple new classes with their file paths
public static addClasses ( array $classes )
$classes array An array of classes

addNamespace() 공개 정적인 메소드

Add a new namespace
public static addNamespace ( string $name )
$name string The namespace name

addNamespaces() 공개 정적인 메소드

Add multiple new namespaces
public static addNamespaces ( array $names )
$names array An array of namespace names

findClass() 보호된 정적인 메소드

Search the namespaces for a matching entry
protected static findClass ( string $class ) : string | null
$class string The class name
리턴 string | null The full path including the namespace or null

getClasses() 공개 정적인 메소드

Return the classes as array.
public static getClasses ( ) : array
리턴 array An array of all classes

getNamespaces() 공개 정적인 메소드

Return the namespaces as array
public static getNamespaces ( ) : array
리턴 array An array of all namespaces

load() 공개 정적인 메소드

To preserve backwards compatibility with Contao 2 extensions, all core classes will be aliased into the global namespace.
public static load ( string $class )
$class string The class name

register() 공개 정적인 메소드

Register the autoloader
public static register ( )

scanAndRegister() 공개 정적인 메소드

Scan the module directories for config/autoload.php files and then register the autoloader on the SPL stack
public static scanAndRegister ( )

프로퍼티 상세

$classes 보호되어 있는 정적으로 프로퍼티

Known classes
protected static array $classes
리턴 array

$namespaces 보호되어 있는 정적으로 프로퍼티

Known namespaces
protected static array $namespaces
리턴 array