ViewLayerData
class ViewLayerData implements IteratorAggregate, Stringable (View source)
This class is used to wrap data before it gets sent to the view layer.
Wrapping data in this class ensures it has consistent escaping and casting applied to it, regardless of what type the original data is.
Traits
A class that can be instantiated or replaced via DI
Constants
META_DATA_NAMES |
Special variable names that can be used to get metadata about values |
Methods
An implementation of the factory method, allows you to create an instance of a class
Creates a class instance by the "singleton" design pattern.
Needed so we can rewind in ScopeManager::next() after getting itemIteratorTotal without throwing an exception.
Checks if a field is set, or if a getter or a method of that name exists.
Check if there is a truthy value or (for ModelData) if the data exists().
Get the raw value of some field/property/method on the data, without wrapping it in ViewLayerData.
Details
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).
__construct(mixed $data, mixed $source = null, string $name = '')
No description
int
getIteratorCount()
Needed so we can rewind in ScopeManager::next() after getting itemIteratorTotal without throwing an exception.
Traversable
getIterator()
No description
bool
__isset(string $name)
Checks if a field is set, or if a getter or a method of that name exists.
We need to check each of these, because we don't currently distinguish between a property, a getter, and a method which means if any of those exists we have to say the field is "set", otherwise template engines may skip fetching the data.
ViewLayerData|null
__get(string $name)
No description
ViewLayerData|null
__call(string $name, array $arguments = [])
No description
string
__toString()
No description
bool
hasDataValue(string|null $name = null, array $arguments = [])
Check if there is a truthy value or (for ModelData) if the data exists().
If $name is passed, we check for a value in the property/method with that name. Otherwise, check if the currently scoped data has a value.
mixed
getRawDataValue(string $name, array $arguments = [])
Get the raw value of some field/property/method on the data, without wrapping it in ViewLayerData.