class Fluent extends Object implements TemplateGlobalProvider (View source)

Bootstrapping and configuration object for Fluet localisation

Properties

public string $class from  SS_Object
protected array $extension_instances from  SS_Object
protected $beforeExtendCallbacks

List of callbacks to call prior to extensions having extend called on them, each grouped by methodName.

from  SS_Object
protected $afterExtendCallbacks

List of callbacks to call after extensions having extend called on them, each grouped by methodName.

from  SS_Object
protected static bool $force_is_frontend

If set, "is_frontend" can be forced to return a value

protected static array $last_set_locale

Indicates the last locale set via Cookies, in order to prevent excessive Cookie setting

protected static FluentSearchAdapter $_search_dapter

Cached search adapter

Methods

public static 
config()

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

protected
beforeExtending(string $method, callable $callback)

Allows user code to hook into Object::extend prior to control being delegated to extensions. Each callback will be reset once called.

protected
afterExtending(string $method, callable $callback)

Allows user code to hook into Object::extend after control being delegated to extensions. Each callback will be reset once called.

public static 
create()

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

public static 
singleton()

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

public static 
create_from_string($classSpec, $firstArg = null)

Create an object from a string representation. It treats it as a PHP constructor without the 'new' keyword. It also manages to construct the object without the use of eval().

public static 
parse_class_spec($classSpec)

Parses a class-spec, such as "Versioned('Stage','Live')", as passed to create_from_string().

public static 
strong_create()

Similar to Object::create(), except that classes are only overloaded if you set the $strong parameter to TRUE when using Object::useCustomClass()

public static 
useCustomClass(string $oldClass, string $newClass, bool $strong = false)

This class allows you to overload classes with other classes when they are constructed using the factory method Object::create()

public static 
string
getCustomClass(string $class)

If a class has been overloaded, get the class name it has been overloaded with - otherwise return the class name

public static 
any
static_lookup($class, $name, null $default = null)

Get the value of a static property of a class, even in that property is declared protected (but not private), without any inheritance, merging or parent lookup if it doesn't exist on the given class.

public static 
get_static($class, $name, $uncached = false) deprecated

No description

public static 
set_static($class, $name, $value) deprecated

No description

public static 
uninherited_static($class, $name, $uncached = false) deprecated

No description

public static 
combined_static($class, $name, $ceiling = false) deprecated

No description

public static 
addStaticVars($class, $properties, $replace = false) deprecated

No description

public static 
add_static_var($class, $name, $value, $replace = false) deprecated

No description

public static 
has_extension(string $classOrExtension, string $requiredExtension = null, bool $strict = false)

Return TRUE if a class has a specified extension.

public static 
add_extension(string $classOrExtension, string $extension = null)

Add an extension to a specific class.

public static 
remove_extension(string $extension)

Remove an extension from a class.

public static 
array
get_extensions(string $class, bool $includeArgumentString = false)

No description

public static 
get_extra_config_sources($class = null)

No description

public
__construct()

No description

public
mixed
__call(string $method, array $arguments)

Attemps to locate and call a method dynamically added to a class at runtime if a default cannot be located

public
bool
hasMethod(string $method)

Return TRUE if a method exists on this object

public
array
allMethodNames(bool $custom = false)

Return the names of all the methods available on this object

protected
defineMethods()

Adds any methods from Extension instances attached to this object.

protected
array
findMethodsFromExtension(object $extension)

No description

protected
addMethodsFrom(string $property, string|int $index = null)

Add all the methods from an object property (which is an Extension) to this object.

protected
removeMethodsFrom(string $property, string|int $index = null)

Add all the methods from an object property (which is an Extension) to this object.

protected
addWrapperMethod(string $method, string $wrap)

Add a wrapper method - a method which points to another method with a different name. For example, Thumbnail(x) can be wrapped to generateThumbnail(x)

protected
createMethod(string $method, string $code)

Add an extra method using raw PHP code passed as a string

public
stat($name, $uncached = false)

No description

public
set_stat($name, $value)

No description

public
uninherited($name)

No description

public
bool
exists()

Return true if this object "exists" i.e. has a sensible value

public
string
parentClass()

No description

public
bool
is_a(string $class)

Check if this class is an instance of a specific class, or has that class as one of its parents

public
string
__toString()

No description

public
mixed
invokeWithExtensions(string $method, mixed $argument = null)

Calls a method if available on both this object and all applied Extensions, and then attempts to merge all results into an array

public
array
extend(string $method, mixed $a1 = null, mixed $a2 = null, mixed $a3 = null, mixed $a4 = null, mixed $a5 = null, mixed $a6 = null, mixed $a7 = null)

Run the given function on all of this object's extensions. Note that this method originally returned void, so if you wanted to return results, you're hosed

public
getExtensionInstance(string $extension)

Get an extension instance attached to this object by name.

public
bool
hasExtension(string $extension)

Returns TRUE if this object instance has a specific extension applied in $extension_instances. Extension instances are initialized at constructor time, meaning if you use add_extension() afterwards, the added extension will just be added to new instances of the extended class. Use the static method has_extension() to check if a class (not an instance) has a specific extension.

public
array
getExtensionInstances()

Get all extension instances for this specific object instance.

public
mixed
cacheToFile(string $method, int $lifetime = 3600, string $ID = false, array $arguments = array())

Cache the results of an instance method in this object to a file, or if it is already cache return the cached results

public
clearCache($method, $ID = false, $arguments = array())

Clears the cache for the given cacheToFile call

protected
mixed
loadCache(string $cache, int $lifetime = 3600)

Loads a cache from the filesystem if a valid on is present and within the specified lifetime

protected
saveCache(string $cache, mixed $data)

Save a piece of cached data to the file system

protected
string
sanitiseCachename(string $name)

Strip a file name of special characters so it is suitable for use as a cache file name

public static 
regenerate_routes()

Forces regeneration of all locale routes

public static 
init()

Initialise routes

public static 
string
current_locale(bool $persist = true)

Gets the current locale

public static 
string
get_request_locale()

Gets the locale requested directly in the request, either via route, post, or query parameters

public static 
string|null
get_persist_locale(string $key = null)

Gets the locale currently set within either the session or cookie.

public static 
set_persist_locale(string $locale, string $key = null)

Specify the locale to persist between sessions, or to use for the locale outside of locale-routed pages (such as in unit tests, custom controllers, etc).

public static 
array
locales(mixed $domain = null)

Retrieves the list of locales

public static 
array
locale_names()

Retrieves the list of locale names as an associative array

public static 
string
locale_native_name(string $locale)

Fetch a native language string from the i18n class via a passed locale in the format "XX_xx". In the event a match cannot be found in any framework resource, an empty string is returned.

public static 
bool
is_domain_mode()

Determine if the website is in domain segmentation mode

public static 
array
domains()

Retrieves any configured domains, assuming the site is running in domain mode.

public static 
domain_for_locale(string $locale)

Determine the home domain for this locale

public static 
string
default_locale(mixed $domain = null)

Retrieves the default locale

public static 
bool
is_frontend(bool $ignoreController = false)

Determines behaviour of locale filter in this request, by detecting whether to present an admin view of the site, or a frontend view.

public static 
bool
is_locale(string $locale)

Determine if a locale code is within the range of configured locales

public static 
bool
disable_default_prefix()

Check if default locale should have prefix disabled

public static 
bool
any_match(string $value, array $patterns)

Helper function to check if the value given is present in any of the patterns.

public static 
string
alias(string $locale)

Determine the alias to use for a specific locale

public static 
db_field_for_locale(string $field, string $locale)

Determine the DB field name to use for the given base field

public static 
install_locale(bool $persist = true)

Installs the current locale into i18n

public static 
string
detect_browser_locale(mixed $domain = null)

Determines the locale best matching the given list of browser locales

public static 
mixed
with_locale(string $locale, callable $callback)

Executes a callback with a locale to temporarily emulate.

public static 
search_adapter()

Retrieves a search adapter for the current database adapter

public static 
string
locale_baseurl(string $locale = null)

Determine the baseurl within a specified $locale.

public static 
array
public static 
bool
isFieldModified(DataObject $object, FormField $field, string|null $locale = null)

Given a field on an object and optionally a locale, compare its locale value against the default locale value to determine if the value is changed at the given locale.

public static 
set_force_is_frontend(bool $force = true)

Sets whether to force "is_frontend" to return true or false. This can be used for situations where the frontend controllers are not involved, e.g. API modules, unit testing or retrieving data programmatically.

Details

static Config_ForClass|null config()

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

Return Value

Config_ForClass|null

protected beforeExtending(string $method, callable $callback)

Allows user code to hook into Object::extend prior to control being delegated to extensions. Each callback will be reset once called.

Parameters

string $method

The name of the method to hook into

callable $callback

The callback to execute

protected afterExtending(string $method, callable $callback)

Allows user code to hook into Object::extend after control being delegated to extensions. Each callback will be reset once called.

Parameters

string $method

The name of the method to hook into

callable $callback

The callback to execute

static SS_Object create()

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

This method first for strong class overloads (singletons & DB interaction), then custom class overloads. If an overload is found, an instance of this is returned rather than the original class. To overload a class, use Object::useCustomClass()

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'); $list = SiteTree::get();

Return Value

SS_Object

static SS_Object singleton()

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

Return Value

SS_Object

The singleton instance

static create_from_string($classSpec, $firstArg = null)

Create an object from a string representation. It treats it as a PHP constructor without the 'new' keyword. It also manages to construct the object without the use of eval().

Construction itself is done with Object::create(), so that Object::useCustomClass() calls are respected.

Object::create_from_string("Versioned('Stage','Live')") will return the result of Versioned::create('Stage', 'Live);

It is designed for simple, clonable objects. The first time this method is called for a given string it is cached, and clones of that object are returned.

If you pass the $firstArg argument, this will be prepended to the constructor arguments. It's impossible to pass null as the firstArg argument.

Object::create_from_string("Varchar(50)", "MyField") will return the result of Vachar::create('MyField', '50');

Arguments are always strings, although this is a quirk of the current implementation rather than something that can be relied upon.

Parameters

$classSpec
$firstArg

static parse_class_spec($classSpec)

Parses a class-spec, such as "Versioned('Stage','Live')", as passed to create_from_string().

Returns a 2-elemnent array, with classname and arguments

Parameters

$classSpec

static SS_Object strong_create()

Similar to Object::create(), except that classes are only overloaded if you set the $strong parameter to TRUE when using Object::useCustomClass()

Return Value

SS_Object

static useCustomClass(string $oldClass, string $newClass, bool $strong = false)

This class allows you to overload classes with other classes when they are constructed using the factory method Object::create()

Parameters

string $oldClass

the class to replace

string $newClass

the class to replace it with

bool $strong

allows you to enforce a certain class replacement under all circumstances. This is used in singletons and DB interaction classes

static string getCustomClass(string $class)

If a class has been overloaded, get the class name it has been overloaded with - otherwise return the class name

Parameters

string $class

the class to check

Return Value

string

the class that would be created if you called Object::create() with the class

static any static_lookup($class, $name, null $default = null)

Get the value of a static property of a class, even in that property is declared protected (but not private), without any inheritance, merging or parent lookup if it doesn't exist on the given class.

Parameters

$class
  • The class to get the static from
$name
  • The property to get from the class
null $default
  • The value to return if property doesn't exist on class

Return Value

any
  • The value of the static property $name on class $class, or $default if that property is not defined

static get_static($class, $name, $uncached = false) deprecated

deprecated

No description

Parameters

$class
$name
$uncached

static set_static($class, $name, $value) deprecated

deprecated

No description

Parameters

$class
$name
$value

static uninherited_static($class, $name, $uncached = false) deprecated

deprecated

No description

Parameters

$class
$name
$uncached

static combined_static($class, $name, $ceiling = false) deprecated

deprecated

No description

Parameters

$class
$name
$ceiling

static addStaticVars($class, $properties, $replace = false) deprecated

deprecated

No description

Parameters

$class
$properties
$replace

static add_static_var($class, $name, $value, $replace = false) deprecated

deprecated

No description

Parameters

$class
$name
$value
$replace

static has_extension(string $classOrExtension, string $requiredExtension = null, bool $strict = false)

Return TRUE if a class has a specified extension.

This supports backwards-compatible format (static Object::has_extension($requiredExtension)) and new format ($object->has_extension($class, $requiredExtension))

Parameters

string $classOrExtension

if 1 argument supplied, the class name of the extension to check for; if 2 supplied, the class name to test

string $requiredExtension

used only if 2 arguments supplied

bool $strict

if the extension has to match the required extension and not be a subclass

static add_extension(string $classOrExtension, string $extension = null)

Add an extension to a specific class.

The preferred method for adding extensions is through YAML config, since it avoids autoloading the class, and is easier to override in more specific configurations.

As an alternative, extensions can be added to a specific class directly in the Object::$extensions array. See SiteTree::$extensions for examples. Keep in mind that the extension will only be applied to new instances, not existing ones (including all instances created through singleton()).

Parameters

string $classOrExtension

Class that should be extended - has to be a subclass of Object

string $extension

Subclass of Extension with optional parameters as a string, e.g. "Versioned" or "Translatable('Param')"

See also

http://doc.silverstripe.org/framework/en/trunk/reference/dataextension

static remove_extension(string $extension)

Remove an extension from a class.

Keep in mind that this won't revert any datamodel additions of the extension at runtime, unless its used before the schema building kicks in (in your _config.php). Doesn't remove the extension from any Object instances which are already created, but will have an effect on new extensions. Clears any previously created singletons through singleton() to avoid side-effects from stale extension information.

Add support for removing extensions with parameters

Parameters

string $extension

Classname of an Extension subclass, without parameters

static array get_extensions(string $class, bool $includeArgumentString = false)

No description

Parameters

string $class
bool $includeArgumentString

Include the argument string in the return array, FALSE would return array("Versioned"), TRUE returns array("Versioned('Stage','Live')").

Return Value

array

Numeric array of either DataExtension classnames, or eval'ed classname strings with constructor arguments.

static get_extra_config_sources($class = null)

No description

Parameters

$class

__construct()

No description

mixed __call(string $method, array $arguments)

Attemps to locate and call a method dynamically added to a class at runtime if a default cannot be located

You can add extra methods to a class using Extensions}, {@link Object::createMethod() or Object::addWrapperMethod()

Parameters

string $method
array $arguments

Return Value

mixed

bool hasMethod(string $method)

Return TRUE if a method exists on this object

This should be used rather than PHP's inbuild method_exists() as it takes into account methods added via extensions

Parameters

string $method

Return Value

bool

array allMethodNames(bool $custom = false)

Return the names of all the methods available on this object

Parameters

bool $custom

include methods added dynamically at runtime

Return Value

array

protected defineMethods()

Adds any methods from Extension instances attached to this object.

All these methods can then be called directly on the instance (transparently mapped through __call()}), or called explicitly through {@link extend().

protected array findMethodsFromExtension(object $extension)

No description

Parameters

object $extension

Return Value

array

protected addMethodsFrom(string $property, string|int $index = null)

Add all the methods from an object property (which is an Extension) to this object.

Parameters

string $property

the property name

string|int $index

an index to use if the property is an array

protected removeMethodsFrom(string $property, string|int $index = null)

Add all the methods from an object property (which is an Extension) to this object.

Parameters

string $property

the property name

string|int $index

an index to use if the property is an array

protected addWrapperMethod(string $method, string $wrap)

Add a wrapper method - a method which points to another method with a different name. For example, Thumbnail(x) can be wrapped to generateThumbnail(x)

Parameters

string $method

the method name to wrap

string $wrap

the method name to wrap to

protected createMethod(string $method, string $code)

Add an extra method using raw PHP code passed as a string

Parameters

string $method

the method name

string $code

the PHP code - arguments will be in an array called $args, while you can access this object by using $obj. Note that you cannot call protected methods, as the method is actually an external function

stat($name, $uncached = false)

No description

Parameters

$name
$uncached

See also

SS_Object::get_static

set_stat($name, $value)

No description

Parameters

$name
$value

See also

SS_Object::set_static

uninherited($name)

No description

Parameters

$name

See also

SS_Object::uninherited_static

bool exists()

Return true if this object "exists" i.e. has a sensible value

This method should be overriden in subclasses to provide more context about the classes state. For example, a DataObject class could return false when it is deleted from the database

Return Value

bool

string parentClass()

No description

Return Value

string

this classes parent class

bool is_a(string $class)

Check if this class is an instance of a specific class, or has that class as one of its parents

Parameters

string $class

Return Value

bool

string __toString()

No description

Return Value

string

the class name

mixed invokeWithExtensions(string $method, mixed $argument = null)

Calls a method if available on both this object and all applied Extensions, and then attempts to merge all results into an array

integrate inheritance rules

Parameters

string $method

the method name to call

mixed $argument

a single argument to pass

Return Value

mixed

array extend(string $method, mixed $a1 = null, mixed $a2 = null, mixed $a3 = null, mixed $a4 = null, mixed $a5 = null, mixed $a6 = null, mixed $a7 = null)

Run the given function on all of this object's extensions. Note that this method originally returned void, so if you wanted to return results, you're hosed

Currently returns an array, with an index resulting every time the function is called. Only adds returns if they're not NULL, to avoid bogus results from methods just defined on the parent extension. This is important for permission-checks through extend, as they use min() to determine if any of the returns is FALSE. As min() doesn't do type checking, an included NULL return would fail the permission checks.

The extension methods are defined during __construct()} in {@link defineMethods().

Parameters

string $method

the name of the method to call on each extension

mixed $a1
mixed $a2
mixed $a3
mixed $a4
mixed $a5
mixed $a6
mixed $a7

Return Value

array

Extension getExtensionInstance(string $extension)

Get an extension instance attached to this object by name.

Parameters

string $extension

Return Value

Extension

bool hasExtension(string $extension)

Returns TRUE if this object instance has a specific extension applied in $extension_instances. Extension instances are initialized at constructor time, meaning if you use add_extension() afterwards, the added extension will just be added to new instances of the extended class. Use the static method has_extension() to check if a class (not an instance) has a specific extension.

Caution: Don't use singleton()->hasExtension() as it will give you inconsistent results based on when the singleton was first accessed.

Parameters

string $extension

Classname of an Extension subclass without parameters

Return Value

bool

array getExtensionInstances()

Get all extension instances for this specific object instance.

See get_extensions() to get all applied extension classes for this class (not the instance).

Return Value

array

Map of DataExtension instances, keyed by classname.

mixed cacheToFile(string $method, int $lifetime = 3600, string $ID = false, array $arguments = array())

Cache the results of an instance method in this object to a file, or if it is already cache return the cached results

Parameters

string $method

the method name to cache

int $lifetime

the cache lifetime in seconds

string $ID

custom cache ID to use

array $arguments

an optional array of arguments

Return Value

mixed

the cached data

clearCache($method, $ID = false, $arguments = array())

Clears the cache for the given cacheToFile call

Parameters

$method
$ID
$arguments

protected mixed loadCache(string $cache, int $lifetime = 3600)

Loads a cache from the filesystem if a valid on is present and within the specified lifetime

Parameters

string $cache

the cache name

int $lifetime

the lifetime (in seconds) of the cache before it is invalid

Return Value

mixed

protected saveCache(string $cache, mixed $data)

Save a piece of cached data to the file system

Parameters

string $cache

the cache name

mixed $data

data to save (must be serializable)

protected string sanitiseCachename(string $name)

Strip a file name of special characters so it is suitable for use as a cache file name

Parameters

string $name

Return Value

string

the name with all special cahracters replaced with underscores

static regenerate_routes()

Forces regeneration of all locale routes

static init()

Initialise routes

static string current_locale(bool $persist = true)

Gets the current locale

Parameters

bool $persist

Attempt to persist any detected locale within session / cookies

Return Value

string

i18n locale code

static string get_request_locale()

Gets the locale requested directly in the request, either via route, post, or query parameters

Return Value

string

The locale, if available

static string|null get_persist_locale(string $key = null)

Gets the locale currently set within either the session or cookie.

Parameters

string $key

ID to retrieve persistant locale from. Will automatically detect if omitted. Either Fluent::config()->persist_id or Fluent::config()->persist_id_cms.

Return Value

string|null

The locale, if available

static set_persist_locale(string $locale, string $key = null)

Specify the locale to persist between sessions, or to use for the locale outside of locale-routed pages (such as in unit tests, custom controllers, etc).

Not to be confused with the temporary locale assigned with {\Fluent::with_locale} .

Parameters

string $locale

Locale to assign

string $key

ID to set the locale against. Will automatically detect if omitted. Either Fluent:::config()->persist_id or Fluent::::config()->persist_id_cms.

static array locales(mixed $domain = null)

Retrieves the list of locales

Parameters

mixed $domain

Domain to determine the locales for. If null, the global list be returned. If true, then the current domain will be used.

Return Value

array

List of locales

static array locale_names()

Retrieves the list of locale names as an associative array

Return Value

array

List of locale names mapped by locale code

static string locale_native_name(string $locale)

Fetch a native language string from the i18n class via a passed locale in the format "XX_xx". In the event a match cannot be found in any framework resource, an empty string is returned.

Parameters

string $locale

e.g. "pt_BR"

Return Value

string

The native language string for that locale e.g. "português (Brazil)"

static bool is_domain_mode()

Determine if the website is in domain segmentation mode

Return Value

bool

static array domains()

Retrieves any configured domains, assuming the site is running in domain mode.

Return Value

array

List of domains and their respective configuration information

static domain_for_locale(string $locale)

Determine the home domain for this locale

Parameters

string $locale

static string default_locale(mixed $domain = null)

Retrieves the default locale

Parameters

mixed $domain

Domain to determine the default locale for. If null, the global default will be returned. If true, then the current domain will be used.

Return Value

string

static bool is_frontend(bool $ignoreController = false)

Determines behaviour of locale filter in this request, by detecting whether to present an admin view of the site, or a frontend view.

If viewing in the CMS items filtered by locale will always be visible, but in the frontend will be filtered as expected.

For the sake of unit tests Fluent assumes a frontend execution environment.

Parameters

bool $ignoreController

Flag to indicate whether the current controller should be ignored, and detection should be performed by inspecting the URL. Used for testing. Defaults to false.

Return Value

bool

Flag indicating if the translation should act on the frontend

static bool is_locale(string $locale)

Determine if a locale code is within the range of configured locales

Parameters

string $locale

Return Value

bool

True if this locale is valid

static bool disable_default_prefix()

Check if default locale should have prefix disabled

Return Value

bool

static bool any_match(string $value, array $patterns)

Helper function to check if the value given is present in any of the patterns.

This function is case sensitive by default.

Parameters

string $value

A string value to check against, potentially with parameters (E.g. 'Varchar(1023)')

array $patterns

A list of strings, some of which may be regular expressions

Return Value

bool

True if this $value is present in any of the $patterns

static string alias(string $locale)

Determine the alias to use for a specific locale

Parameters

string $locale

Locale in language_Country format

Return Value

string

Locale in its original form, or its alias if one exists

static db_field_for_locale(string $field, string $locale)

Determine the DB field name to use for the given base field

Parameters

string $field

DB field name

string $locale

Locale to use

static install_locale(bool $persist = true)

Installs the current locale into i18n

Parameters

bool $persist

Attempt to persist any detected locale within session / cookies

static string detect_browser_locale(mixed $domain = null)

Determines the locale best matching the given list of browser locales

Parameters

mixed $domain

Domain to determine the locales for. If null, the global list be returned. If true, then the current domain will be used.

Return Value

string

The matching locale, or null if none could be determined

static mixed with_locale(string $locale, callable $callback)

Executes a callback with a locale to temporarily emulate.

Warning: Existing DataObjects will contain fields in the actual locale if already lazily loaded, or if used within the callback, will populate itself with the overriding locale. The inverse will occur once the callback is complete. The best practice is to consider this a sandbox, and re-requery all objects required, discarding these afterwards.

Parameters

string $locale

The locale to set

callable $callback

The callback

Return Value

mixed

The returned value from the $callback

static FluentSearchAdapter search_adapter()

Retrieves a search adapter for the current database adapter

Return Value

FluentSearchAdapter

static string locale_baseurl(string $locale = null)

Determine the baseurl within a specified $locale.

Parameters

string $locale

Locale, or null to use current locale

Return Value

string

static array get_template_global_variables()

No description

Return Value

array

Returns an array of items. Each key => value pair is one of three forms:

  • template name (no key)
  • template name => method name
  • template name => array(), where the array can contain these key => value pairs
    • "method" => method name
    • "casting" => casting class to use (i.e., Varchar, HTMLText, etc)

static bool isFieldModified(DataObject $object, FormField $field, string|null $locale = null)

Given a field on an object and optionally a locale, compare its locale value against the default locale value to determine if the value is changed at the given locale.

Parameters

DataObject $object
FormField $field
string|null $locale

Optional: if not provided, will be gathered from the request

Return Value

bool

static set_force_is_frontend(bool $force = true)

Sets whether to force "is_frontend" to return true or false. This can be used for situations where the frontend controllers are not involved, e.g. API modules, unit testing or retrieving data programmatically.

Parameters

bool $force