Configuration
Below is a list of available configuration with default values.
"example" => [
"type" => "anomaly.field_type.addon",
"config" => [
"default_value" => null,
"type" => null,
"search" => null,
"theme_type" => null,
"handler" => "Anomaly\AddonFieldType\Handler\DefaultHandler@handle"
]
]
Configuration
Key | Example | Description |
---|---|---|
default_value |
anomaly.module.files |
The default value. |
type |
module |
If defined only addons of the specified type will be displayed. Valid options are |
search |
anomaly.module.users::authentication.* |
The extension search option will search and return only extensions with a provision string that matches your search. |
theme_type |
admin |
Restrict what type of themes are returned. Valid options are |
handler |
Handlers let you override control of the options logic. |
Option Handlers
Option handlers are responsible for setting the available options on the field type. You can define your own option handler to add your own logic to available dropdown options.
You can define custom handlers as a callable string where @handle
will be assumed if no method is provided:
"handler" => /Example/Test/CustomOptions::class // Assumes @handle
Option handlers can also a handler with a closure:
"handler" => function (AddonFieldType $fieldType, ExampleModule $module) {
$fieldType->setOptions(
[
"anomaly.module.example" => $module->getName()
]
);
}
Writing Option Handlers
Writing custom option handlers is easy. To begin create a class with the method you defined in the config option.
"handler" => "App/Example/MyOptions@handle"
The callable string is called via Laravel's service container. The AddonFieldType $fieldType
is passed as an argument.
<?php namespace App/Example;
class MyOptions
{
public function handle(AddonFieldType $fieldType)
{
$fieldType->setOptions(
[
"anomaly.module.example" => 'Example'
]
);
}
}