\ViewableWrapper
These are a couple classes that link the dataobject classes to Silverstripe They should generally be subclassed for arrangements, etc.
- Author: Mark GUinn
Synopsis
class ViewableWrapper
extends ViewableData
{
- // members
- protected $varName;
- protected boolean $liveVars = true;
- protected array $liveVarsUnescaped = ;
- // methods
- public void __construct()
- public void getRawObject()
- public void __get()
- public bool isLiveVar()
- public void obj()
- protected void wrapObject()
- public void AsDate()
- public void AsCurrency()
- public void AsPhone()
- public void DebugMe()
- public string castingHelper()
- public void getStaticInit()
- public ViewableWrapper setVar()
- public string getVar()
- public ViewableWrapper setLiveVars()
- public bool|array getLiveVars()
- public ViewableWrapper setUnescapedVars()
- public array getUnescapedVars()
Hierarchy
Extends
- ViewableData
Members
protected
-
$liveVars
should the __get method make properties "live" in static published documents? var name must be set in order for this to work and the variable it refers to should somehow be set up in getStaticInit() - e.g from the session or a database call or something. -
$liveVarsUnescaped
normally live vars are escaped using htmlentities automatically, but any in this list will be outputted as-is -
$varName
if using static publishing, this is the variable name
Methods
protected
- wrapObject() — if an object isn't already wrapped in Silverstripe's stuff, wrap it appropriately either in a viewableWrapper or dataobject set
public
- __construct() — sets up the object
- AsCurrency() — returns the given field as a casted date object
- AsDate() — returns the given field as a casted date object
- AsPhone() — returns the given field as a uniformly formatted phone # !todo - does this need to work differently for internationals?
- DebugMe()
- __get() — Insures that any array or object is wrapped properly
- castingHelper() — Return the "casting helper" (a piece of PHP code that when evaluated creates a casted value object) for a field on this object. MODIFIED TO LEAVE FAILOVER ALONE (so it doesn't have to inherit Object).
- getLiveVars()
- getRawObject() — returns the source object
- getStaticInit() — This is called by LivePubHelper to retrieve initialization code that gets added to the top of the cached page.
- getUnescapedVars()
- getVar()
- isLiveVar() — Is this variable live in published mode?
- obj() — If we're publishing, returns proper php
- setLiveVars()
- setUnescapedVars() — Sets which variables should NOT be escaped.
- setVar() — Set the variable name used for nested wrappers in published mode.