HTMLEditorConfig
abstract class HTMLEditorConfig (View source)
A PHP version of TinyMCE's configuration, to allow various parameters to be configured on a site or section basis
There can be multiple HTMLEditorConfig's, which should always be created / accessed using HTMLEditorConfig::get. You can then set the currently active config using set_active. The order of precedence for which config is used is (lowest to highest):
- default_config config setting
- Active config assigned
- Config name assigned to HTMLEditorField
- Config instance assigned to HTMLEditorField
Typically global config changes should set the active config.
The default config class can be changed via dependency injection to replace HTMLEditorConfig.
Traits
Provides extensions to this object to integrate it with standard config API methods.
A class that can be instantiated or replaced via DI
Config options
default_config | string | Name of default config. This will be ignored if $current is assigned a value. |
|
user_themes | array | List of themes defined for the frontend |
Properties
protected static | HTMLEditorConfig[] | $configs | Array of registered configurations |
|
protected static | string | $current | Identifier key of current config. This will match an array key in $configs. |
|
protected static | array | $current_themes | List of the current themes set for this config |
Methods
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
Gets the uninherited value for the given config option
An implementation of the factory method, allows you to create an instance of a class
Creates a class instance by the "singleton" design pattern.
Get the HTMLEditorConfig object for the given identifier. This is a correct way to get an HTMLEditorConfig instance - do not call 'new'
Assign a new config, or clear existing, for the given identifier
Gets the current themes, if it is not set this will fallback to config
Set the currently active configuration object. Note that the existing active config will not be renamed to the new identifier.
Get the currently active configuration identifier. Will fall back to default_config if unassigned.
Get the available configurations as a map of friendly_name to configuration name.
Set multiple options. This does not merge recursively, but only at the top level.
Associative array of data-attributes to apply to the underlying text-area
Provide additional schema data for the field this object configures
Details
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
static Injectable
create(mixed ...$args)
An implementation of the factory method, allows you to create an instance of a class
This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.
This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create(SiteTree::class); $list = SiteTree::get();
static Injectable
singleton(string $class = null)
Creates a class instance by the "singleton" design pattern.
It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).
static HTMLEditorConfig
get(string $identifier = null)
Get the HTMLEditorConfig object for the given identifier. This is a correct way to get an HTMLEditorConfig instance - do not call 'new'
static HTMLEditorConfig
set_config(string $identifier, HTMLEditorConfig $config = null)
Assign a new config, or clear existing, for the given identifier
static array
getThemes()
Gets the current themes, if it is not set this will fallback to config
static
setThemes(array $themes)
Sets the current theme
static
set_active_identifier(string $identifier)
Set the currently active configuration object. Note that the existing active config will not be renamed to the new identifier.
static string
get_active_identifier()
Get the currently active configuration identifier. Will fall back to default_config if unassigned.
static HTMLEditorConfig
get_active()
Get the currently active configuration object
static HTMLEditorConfig
set_active(HTMLEditorConfig $config)
Assigns the currently active config an explicit instance
static array
get_available_configs_map()
Get the available configurations as a map of friendly_name to configuration name.
abstract mixed
getOption(string $key)
Get the current value of an option
abstract $this
setOption(string $key, mixed $value)
Set the value of one option
abstract $this
setOptions(array $options)
Set multiple options. This does not merge recursively, but only at the top level.
abstract array
getAttributes()
Associative array of data-attributes to apply to the underlying text-area
abstract
init()
Initialise the editor on the client side
array
getConfigSchemaData()
Provide additional schema data for the field this object configures