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:

  1. Composer autoloading: Composer packages are autoloaded according to the given settings in the package's composer.json file.

  2. 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

Methods

__construct(string $extension, array $options, object $Automad)

Create an instance of the given extension, call the extension method and look for all needed assets.

array
getAssets()

Return an array of assets of the extension.

string
getOutput()

Return the output of the extension.

Details

__construct(string $extension, array $options, object $Automad)

Create an instance of the given extension, call the extension method and look for all needed assets.

Parameters

string $extension
array $options
object $Automad

array getAssets()

Return an array of assets of the extension.

Return Value

array The array of files

string getOutput()

Return the output of the extension.

Return Value

string The output returned by the extension