Configuration
This section will go over how to utilize the configuration values you have defined.
Configuration Interface
This section will go over the \Anomaly\ConfigurationModule\Configuration\Contract\ConfigurationInterface
class.
ConfigurationInterface::field()[](#usage/configuration/configuration-interface/configuratio
ninterface-field)
The field
method returns the field type instance for the value or null
if the configuration field no longer exists.
Returns: \Anomaly\Streams\Platform\Addon\FieldType\FieldType
or null
Example
$config = $configura
tion->get('anomaly.extension.xml_feed_widget::url');
if ($field = $config->field(
)) {
echo $field->getValue();
}
Configuration Repository
This section will go over the \Anomaly\ConfigurationModule\Configuration\Contract\ConfigurationRepositoryInterface
class.
ConfigurationRepositoryInterface::get()[](#usage/configuration/configuration-repository/co
nfigurationrepositoryinterface-get)
The get
method returns the configuration instance.
Returns: \Anomaly\ConfigurationModule\Configuration\Contract\ConfigurationInterface
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$key |
true |
string |
none |
The configuration key. |
$scope |
true |
mixed |
none |
The configuration scope. |
Example
$url = $configuratio
n->value(
'anomaly.extension.xml_feed_widget::url',
$widget->getId()
);
echo $url->getValue();
ConfigurationRepositoryInterface::set()
The set
method allows you to set a configuration value.
Values are passed through the configuration field's modifier.{.tip}
Returns: boolean
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$key |
true |
string |
none |
The configuration key. |
$scope |
true |
string |
none |
The configuration scope. |
$value |
true |
mixed |
none |
The configuration value. |
Example
$configuration-><
/span>set(
'anomaly.extension.xml_feed_widget::url',
$this->widget->getId(),
'http://www.pyrocms.com/posts/rss.xml'
);
ConfigurationRepositoryInterface::value()[](#usage/configuration/configuration-repository/
configurationrepositoryinterface-value)
The value
method returns the value as the configuration field type normally would with getType
.
Returns: mixed
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$key |
true |
string |
none |
The configuration key. |
$key |
true |
string |
none |
The configuration key. |
$default |
false |
mixed |
null |
The default value. |
Example
$value = $configurat
ion->value(
'anomaly.extension.xml_feed_widget::url',
$this->widget->getId(),
'http://www.pyrocms.com/posts/rss.xml'
)
ConfigurationRepositoryInterface::presenter()[](#usage/configuration/configuration-reposit
ory/configurationrepositoryinterface-presenter)
The presenter
method returns the configuration value's field type presenter or null
if the configuration no longer exists.
Returns: \Anomaly\Streams\Platform\Addon\FieldType\FieldTypePresenter
or null
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$key |
true |
string |
none |
The configuration key. |
$scope |
true |
mixed |
none |
The configuration scope. |
Example
$url = $configuratio
n->value(
'anomaly.extension.xml_feed_widget::url',
$this->widget->getId()
);
echo $url->link('Example Link!');<
/span>