Extension
class Extension (View source)
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
Properties
private | $assets | The array of found assets. | |
private | $output | The retured output of the extension. |
Methods
Create an instance of the given extension, call the extension method and look for all needed assets.
Return an array of assets of the extension.
Return the output of the extension.
Collect all assets (CSS & JS files) belonging to $class and store them in $this->assets.
Details
at line 104
__construct(string $extension, array $options, Automad $Automad)
Create an instance of the given extension, call the extension method and look for all needed assets.
at line 156
array
getAssets()
Return an array of assets of the extension.
at line 165
string
getOutput()
Return the output of the extension.
at line 174
private
collectAssets(string $class)
Collect all assets (CSS & JS files) belonging to $class and store them in $this->assets.