class FluentDirectorExtension extends Extension (View source)

Fluent extension for \SilverStripe\Control\Director to apply routing rules for locales

Traits

Provides extensions to this object to integrate it with standard config API methods.

Config options

allowed_actions

This is used by extensions designed to be applied to controllers.

from  Extension
detect_locale bool

Determine if the site should detect the browser locale for new users. Turn this off to disable 302 redirects on the home page.

remember_locale bool

Determine if the locale should be remembered across multiple sessions via cookies. If this is left on then visitors to the home page will be redirected to the locale they last viewed. This may interefere with some applications and can be turned off to prevent unexpected redirects.

query_param string

Request parameter to store the locale in

disable_default_prefix bool

Allow the prefix for the default Locale (IsDefault = 1) to be disabled

force_domain bool

Whether to force "domain mode"

Properties

protected object $owner

The object this extension is applied to.

from  Extension

Methods

public
__construct()

No description

public static 
add_to_class(string $class, string $extensionClass, mixed $args = null)

Called when this extension is added to a particular class

public
setOwner(object $owner)

Set the owner of this extension.

public
mixed
withOwner(mixed $owner, callable $callback, array $args = [])

Temporarily modify the owner. The original owner is ensured to be restored

public
clearOwner()

Clear the current owner, and restore extension to the state prior to the last setOwner()

public
object
getOwner()

Returns the owner of this extension.

public static 
string
get_classname_without_arguments(string $extensionStr)

Helper method to strip eval'ed arguments from a string that's passed to DataObject::$extensions or Object::add_extension().

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
updateRules(array $rules)

Forces regeneration of all locale routes

protected
array
getExplicitRoutes(array $originalRules)

Generate an array of explicit routing rules for each locale

protected
string
getRuleController(array|string $existingRule, Locale $localeObj)

Get controller that fluent should inject

protected
array
insertRuleBefore(array $rules, string $key, array $rule, bool $prependIfMissing = true)

Inserts the given rule(s) before another rule

Details

__construct()

No description

static add_to_class(string $class, string $extensionClass, mixed $args = null)

Called when this extension is added to a particular class

Parameters

string $class
string $extensionClass
mixed $args

setOwner(object $owner)

Set the owner of this extension.

Parameters

object $owner

The owner object

mixed withOwner(mixed $owner, callable $callback, array $args = [])

Temporarily modify the owner. The original owner is ensured to be restored

Parameters

mixed $owner

Owner to set

callable $callback

Callback to invoke

array $args

Args to pass to callback

Return Value

mixed

clearOwner()

Clear the current owner, and restore extension to the state prior to the last setOwner()

object getOwner()

Returns the owner of this extension.

Return Value

object

static string get_classname_without_arguments(string $extensionStr)

Helper method to strip eval'ed arguments from a string that's passed to DataObject::$extensions or Object::add_extension().

Parameters

string $extensionStr

E.g. "Versioned('Stage','Live')"

Return Value

string

Extension classname, e.g. "Versioned"

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

updateRules(array $rules)

Forces regeneration of all locale routes

Parameters

array $rules

protected array getExplicitRoutes(array $originalRules)

Generate an array of explicit routing rules for each locale

Parameters

array $originalRules

Return Value

array

protected string getRuleController(array|string $existingRule, Locale $localeObj)

Get controller that fluent should inject

Parameters

array|string $existingRule
Locale $localeObj

Return Value

string

Class name of controller to use

protected array insertRuleBefore(array $rules, string $key, array $rule, bool $prependIfMissing = true)

Inserts the given rule(s) before another rule

Parameters

array $rules

Array of rules to insert before

string $key

Rule to insert the new rules before

array $rule

New Rules to insert

bool $prependIfMissing

Prepend the new rules if the insert before rule cannot be found

Return Value

array

Resulting array of rules