The Extension class provides an interface for calling an extension from a template file. There are two options for autoloading extension classes:
- Composer autoloading:
Composer packages are autoloaded according to the given settings in the package's composer.json file.
- Local extensions with simple autoloading:
A local extension is basically called by the subdirectory name within the "/packages" directory. The file name within that subdirectory must have the basename of that directory followed by ".php". Both, class and method name, must be the basename of the directory as well.
In case of extensions grouped in a subdirectory of "/packages", the name of that directory has to be the namespace, in that way that the namespace reflects the actual directory structure without the last directory containing the actual .php file.
Example 1 - Single extension: An extension call like <@ example1 @> would load the file "/packages/example1/example1.php", create an instance of the class "\example1" ($object) and call the method "$object->example1()" of that class. The namespace would just be "\". The full naming scheme would be: - namespace: \ - directory: /packages/example1 (must be lowercase) - file: /packages/example1/example1.php (must be lowercase) - class: Example1 - method: Example1
Example 2 - Extension in a subdirectory (like a vendor name): An extension call like <@ vendor/example2 @> would load the file "/packages/vendor/example2/example2.php", create an instance of the class "\vendor\example2" ($object) and call the method "$object->example2()" of that class. The namespace in this case would be "\vendor". The full naming scheme would be: - namespace: \vendor - directory: /packages/vendor/example2 (must be lowercase) - file: /packages/vendor/example2/example2.php (must be lowercase) - class: Example2 - method: Example2
Copyright: Copyright (c) 2016-2019 by Marc Anton Dahmen - http://marcdahmen.de
License: license - http://automad.org/license
Author: Marc Anton Dahmen
Located at core/extension.php