Nobrainer\Elemental\Settings\ElementSettingExtension
Synopsis
class ElementSettingExtension
extends DataExtension
{
- // members
- private static string $title = '';
- private static string $column = 'BaseSetting';
- private static string $rootTab = 'Root.Settings';
- private static $cssBase = NULL;
- private static string $settingTab = 'Main';
- private static array $fallbackSource = ;
- private static string $defaultValue = '';
- private static array $settings = ;
- private static array $db = ;
- private bool $hasEncoded = false;
- // methods
- public void updateCMSFields()
- private void ensureMainTab()
- public void onBeforeWrite()
- protected TemplateData prepareTemplateData()
- protected mixed getSetting()
- protected array getAllSettings()
- protected array getSettings()
- protected void getTitle()
- protected void getColumn()
- protected void getCssBase()
- protected void getDefaultValue()
- protected void getTab()
- protected string getNameFor()
- protected string getFieldFor()
- protected string getLabelFor()
- protected array getSourceFor()
- protected mixed getValueFor()
- protected array getColumnArray()
- protected stdClass getColumnObject()
- protected ViewableData getViewableColumnData()
- protected string toMeString()
- protected mixed|string getColumnValue()
- protected void setColumnValues()
- protected array getOwnerConfig()
- protected mixed decodeValues()
- protected void encodeValues()
Hierarchy
Extends
- SilverStripe\ORM\DataExtension
Uses
- SilverStripe\Core\Config\Configurable
Members
private
- $column
—
string
The column to write to the database. - $cssBase
—
string
The base of the css class name to be used in generation of the unique $Me string. - $db
—
array
The DB array works like usually in SilverStripe. - $defaultValue
—
string
The default value to set in the field(s). - $fallbackSource
—
string
In case no available source values are set, output a default value. - $hasEncoded
—
Nobrainer\Elemental\Settings\bool
Because of a glitch in SilverStripe Versioned, it is necessary to escape the onBeforeWrite() hook after saving once, since SilverStripe will overwrite values on subsequent writes in the same cycle, resulting in unset values every time. - $rootTab
—
string
The tab-root to add the settings to. - $settingTab
—
string
The tab to add this setting to. - $settings
—
array
An array of adjustable settings for this object. - $title
—
string
The title of this setting extension.
Methods
private
- ensureMainTab() — Ensure the "Main" tab is always the first settings tab.
protected
- decodeValues() — Decode the JSON values in the setting's column.
- encodeValues() — Encode and store the setting's values as JSON in the respective column.
- getAllSettings() — Get all available settings regardless of configuration.
- getColumn()
- getColumnArray() — Get the complex value for this setting extension as an array.
- getColumnObject() — Get the complex value for this setting extension as an object.
- getColumnValue() — Get the given setting from the column.
- getCssBase()
- getDefaultValue()
- getFieldFor() — Get field type for the given setting.
- getLabelFor() — Get the front end label for the given setting.
- getNameFor() — Get a unique name for the given setting to avoid CMS field naming collision.
- getOwnerConfig() — Get the config for the owner of this setting.
- getSetting() — Get a setting with the given name.
- getSettings() — Get the actual settings as a result of the owner's declared constraints.
- getSourceFor() — Get source for the given setting's field.
- getTab()
- getTitle()
- getValueFor() — Get the current value for the given setting.
- getViewableColumnData() — Get a ViewableData instance with mapped settings values.
- prepareTemplateData() — Use a custom ArrayData instance to expose a "forTemplate" approach to rendering a setting in the template, while keeping the option for accessing single variables explicitly.
- setColumnValues() — Set the setting's value in the respective column.
- toMeString() — Generate a string that represents this object, which can be useful as a css class name
public
- onBeforeWrite() — Encode values into a JSON object and store the object in the database.
- updateCMSFields() — Dynamically create CMS fields according to the names declared in the "$settings" array.