class SSViewer_DataPresenter extends SSViewer_Scope (View source)

deprecated 5.4.0 Will be merged into SilverStripe\TemplateEngine\ScopeManager

This extends SSViewer_Scope to mix in data on top of what the item provides. This can be "global" data that is scope-independant (like BaseURL), or type-specific data that is layered on top cross-cut like (like $FirstLast etc).

Constants

ITEM

ITEM_ITERATOR

ITEM_ITERATOR_TOTAL

POP_INDEX

UP_INDEX

CURRENT_INDEX

ITEM_OVERLAY

Properties

protected object $item

The current "global" item (the one any lookup starts from)

from  SSViewer_Scope
protected Iterator $itemIterator

If we're looping over the current "global" item, here's the iterator that tracks with item we're up to

from  SSViewer_Scope
protected int $itemIteratorTotal

Total number of items in the iterator

from  SSViewer_Scope
protected array|null $overlay

Overlay variables. Take precedence over anything from the current scope

protected bool $preserveOverlay

Flag for whether overlay should be preserved when pushing a new scope

protected array $underlay

Underlay variables. Concede precedence to overlay variables or anything from the current scope

Methods

public
__construct($item, array $overlay = null, array $underlay = null, SSViewer_Scope $inheritedScope = null)

No description

public
object
getItem() deprecated

Returns the current "active" item

public
getCurrentItem()

No description

public
locally()

Called at the start of every lookup chain by SSTemplateParser to indicate a new lookup from local scope

public
resetLocalScope()

Reset the local scope - restores saved state to the "global" item stack. Typically called after a lookup chain has been completed

public
mixed
getObj(string $name, array $arguments = [], bool $cache = false, string $cacheName = null)

No description

public
$this
obj(string $name, array $arguments = [], bool $cache = false, string $cacheName = null)

$Up and $Top need to restore the overlay from the parent and top-level scope respectively.

public
object
self()

Gets the current object and resets the scope.

public
pushScope()

Store the current overlay (as it doesn't directly apply to the new scope that's being pushed). We want to store the overlay against the next item "up" in the stack (hence upIndex), rather than the current item, because SSViewer_Scope::obj() has already been called and pushed the new item to the stack by this point

public
popScope()

Now that we're going to jump up an item in the item stack, we need to restore the overlay that was previously stored against the next item "up" in the stack from the current one

public
mixed
next()

Fast-forwards the current iterator to the next item

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

No description

protected
array
getItemStack()

No description

protected
setItemStack(array $stack)

No description

protected
int|null
getUpIndex()

No description

protected
cacheGlobalProperties()

Build cache of global properties

protected
cacheIteratorProperties()

Build cache of global iterator properties

protected
array
getPropertiesFromProvider($interfaceToQuery, $variableMethod, $createObject = false)

No description

public
array|null
getInjectedValue(string $property, array $params, bool $cast = true)

Look up injected value - it may be part of an "overlay" (arguments passed to <% include %>), set on the current item, part of an "underlay" ($Layout or $Content), or an iterator/global property

protected
array
processTemplateOverride(string $property, array $overrides)

Evaluate a template override. Returns an array where the presence of a 'value' key indiciates whether an override was successfully found, as null is a valid override value

protected
array
getValueSource(string $property)

Determine source to use for getInjectedValue. Returns an array where the presence of a 'source' key indiciates whether a value source was successfully found, as a source may be a null value returned from an override

protected
castValue(mixed $value, array $source)

Ensure the value is cast safely

Details

__construct($item, array $overlay = null, array $underlay = null, SSViewer_Scope $inheritedScope = null)

No description

Parameters

$item
array $overlay
array $underlay
SSViewer_Scope $inheritedScope

object getItem() deprecated

deprecated 5.4.0 use getCurrentItem() instead.

Returns the current "active" item

Return Value

object

getCurrentItem()

No description

SSViewer_Scope locally()

Called at the start of every lookup chain by SSTemplateParser to indicate a new lookup from local scope

Return Value

SSViewer_Scope

resetLocalScope()

Reset the local scope - restores saved state to the "global" item stack. Typically called after a lookup chain has been completed

mixed getObj(string $name, array $arguments = [], bool $cache = false, string $cacheName = null)

No description

Parameters

string $name
array $arguments
bool $cache
string $cacheName

Return Value

mixed

$this obj(string $name, array $arguments = [], bool $cache = false, string $cacheName = null)

$Up and $Top need to restore the overlay from the parent and top-level scope respectively.

Parameters

string $name
array $arguments
bool $cache
string $cacheName

Return Value

$this

object self()

Gets the current object and resets the scope.

Return Value

object

SSViewer_Scope pushScope()

Store the current overlay (as it doesn't directly apply to the new scope that's being pushed). We want to store the overlay against the next item "up" in the stack (hence upIndex), rather than the current item, because SSViewer_Scope::obj() has already been called and pushed the new item to the stack by this point

Return Value

SSViewer_Scope

SSViewer_Scope popScope()

Now that we're going to jump up an item in the item stack, we need to restore the overlay that was previously stored against the next item "up" in the stack from the current one

Return Value

SSViewer_Scope

mixed next()

Fast-forwards the current iterator to the next item

Return Value

mixed

mixed __call(string $name, array $arguments)

No description

Parameters

string $name
array $arguments

Return Value

mixed

protected array getItemStack()

No description

Return Value

array

protected setItemStack(array $stack)

No description

Parameters

array $stack

protected int|null getUpIndex()

No description

Return Value

int|null

protected cacheGlobalProperties()

Build cache of global properties

protected cacheIteratorProperties()

Build cache of global iterator properties

protected array getPropertiesFromProvider($interfaceToQuery, $variableMethod, $createObject = false)

No description

Parameters

$interfaceToQuery
$variableMethod
$createObject

Return Value

array

array|null getInjectedValue(string $property, array $params, bool $cast = true)

Look up injected value - it may be part of an "overlay" (arguments passed to <% include %>), set on the current item, part of an "underlay" ($Layout or $Content), or an iterator/global property

Parameters

string $property

Name of property

array $params
bool $cast

If true, an object is always returned even if not an object.

Return Value

array|null

protected array processTemplateOverride(string $property, array $overrides)

Evaluate a template override. Returns an array where the presence of a 'value' key indiciates whether an override was successfully found, as null is a valid override value

Parameters

string $property

Name of override requested

array $overrides

List of overrides available

Return Value

array

An array with a 'value' key if a value has been found, or empty if not

protected array getValueSource(string $property)

Determine source to use for getInjectedValue. Returns an array where the presence of a 'source' key indiciates whether a value source was successfully found, as a source may be a null value returned from an override

Parameters

string $property

Return Value

array

An array with a 'source' key if a value source has been found, or empty if not

protected DBField castValue(mixed $value, array $source)

Ensure the value is cast safely

Parameters

mixed $value
array $source

Return Value

DBField