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

public static 
config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

public
mixed
stat(string $name) deprecated

Get inherited config value

public
mixed
uninherited(string $name)

Gets the uninherited value for the given config option

public
$this
set_stat(string $name, mixed $value) deprecated

Update the config value for a given property

public static 
create(mixed ...$args)

An implementation of the factory method, allows you to create an instance of a class

public static 
singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

public static 
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'

public static 
set_config(string $identifier, HTMLEditorConfig $config = null)

Assign a new config, or clear existing, for the given identifier

public static 
array
getThemes()

Gets the current themes, if it is not set this will fallback to config

public static 
setThemes(array $themes)

Sets the current theme

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

public static 
string
get_active_identifier()

Get the currently active configuration identifier. Will fall back to default_config if unassigned.

public static 
get_active()

Get the currently active configuration object

public static 
set_active(HTMLEditorConfig $config)

Assigns the currently active config an explicit instance

public static 
array
get_available_configs_map()

Get the available configurations as a map of friendly_name to configuration name.

public
mixed
getOption(string $key)

Get the current value of an option

public
$this
setOption(string $key, mixed $value)

Set the value of one option

public
$this
setOptions(array $options)

Set multiple options. This does not merge recursively, but only at the top level.

public
array
getAttributes()

Associative array of data-attributes to apply to the underlying text-area

public
init()

Initialise the editor on the client side

public
array
getConfigSchemaData()

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, .....).

Return Value

Config_ForClass

mixed stat(string $name) deprecated

deprecated 5.0 Use ->config()->get() instead

Get inherited config value

Parameters

string $name

Return Value

mixed

mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

$this set_stat(string $name, mixed $value) deprecated

deprecated 5.0 Use ->config()->set() instead

Update the config value for a given property

Parameters

string $name
mixed $value

Return Value

$this

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();

Parameters

mixed ...$args

Return Value

Injectable

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

Parameters

string $class

Optional classname to create, if the called class should not be used

Return Value

Injectable

The singleton instance

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'

Parameters

string $identifier

The identifier for the config set. If omitted, the active config is returned.

Return Value

HTMLEditorConfig

The configuration object. This will be created if it does not yet exist for that identifier

static HTMLEditorConfig set_config(string $identifier, HTMLEditorConfig $config = null)

Assign a new config, or clear existing, for the given identifier

Parameters

string $identifier

A specific identifier

HTMLEditorConfig $config

Config to set, or null to clear

Return Value

HTMLEditorConfig

The assigned config

static array getThemes()

Gets the current themes, if it is not set this will fallback to config

Return Value

array

static setThemes(array $themes)

Sets the current theme

Parameters

array $themes

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.

Parameters

string $identifier

The identifier for the config set

static string get_active_identifier()

Get the currently active configuration identifier. Will fall back to default_config if unassigned.

Return Value

string

The active configuration identifier

static HTMLEditorConfig get_active()

Get the currently active configuration object

Return Value

HTMLEditorConfig

The active configuration object

static HTMLEditorConfig set_active(HTMLEditorConfig $config)

Assigns the currently active config an explicit instance

Parameters

HTMLEditorConfig $config

Return Value

HTMLEditorConfig

The given config

static array get_available_configs_map()

Get the available configurations as a map of friendly_name to configuration name.

Return Value

array

abstract mixed getOption(string $key)

Get the current value of an option

Parameters

string $key

The key of the option to get

Return Value

mixed

The value of the specified option

abstract $this setOption(string $key, mixed $value)

Set the value of one option

Parameters

string $key

The key of the option to set

mixed $value

The value of the option to set

Return Value

$this

abstract $this setOptions(array $options)

Set multiple options. This does not merge recursively, but only at the top level.

Parameters

array $options

The options to set, as keys and values of the array

Return Value

$this

abstract array getAttributes()

Associative array of data-attributes to apply to the underlying text-area

Return Value

array

abstract init()

Initialise the editor on the client side

array getConfigSchemaData()

Provide additional schema data for the field this object configures

Return Value

array