class SSViewer_FromString extends SSViewer

Special SSViewer that will process a template passed as a string, rather than a filename.

Traits

Provides extensions to this object to integrate it with standard config API methods.
A class that can be instantiated or replaced via DI

Constants

DEFAULT_THEME

Identifier for the default theme

PUBLIC_THEME

Identifier for the public theme

Config options

cache_template bool The global template caching behaviour if no instance override is specified

Methods

static Config_ForClass
config()

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

mixed
stat(string $name) deprecated

Get inherited config value

mixed
uninherited(string $name)

Gets the uninherited value for the given config option

$this
set_stat(string $name, mixed $value) deprecated

Update the config value for a given property

static Injectable
create(array $args)

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

static Injectable
singleton(string $class = null)

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

__construct(string $content, TemplateParser $parser = null)

No description

static 
flush()

Triggered early in the request when someone requests a flush.

from SSViewer
static SSViewer
fromString(string $content, bool|void $cacheTemplate = null)

Create a template from a string instead of a .ss file

from SSViewer
static 
set_themes(array $themes = [])

Assign the list of active themes to apply.

from SSViewer
static 
add_themes(array $themes = [])

Add to the list of active themes to apply

from SSViewer
static array
get_themes()

Get the list of active themes

from SSViewer
static 
set_theme(string $theme) deprecated

No description

from SSViewer
static array
get_templates_by_class(string|object $classOrObject, string $suffix = '', string $baseClass = null)

Traverses the given the given class context looking for candidate template names which match each item in the class hierarchy. The resulting list of template candidates may or may not exist, but you can invoke {see SSViewer::chooseTemplate} on any list to determine the best candidate based on the current themes.

from SSViewer
static ViewableData
topLevel()

Get the current item being processed

from SSViewer
bool
getRewriteHashLinks()

Check if rewrite hash links are enabled on this instance

from SSViewer
$this
setRewriteHashLinks(bool $rewrite)

Set if hash links are rewritten for this instance

from SSViewer
static bool
getRewriteHashLinksDefault()

Get default value for rewrite hash links for all modules

from SSViewer
static 
setRewriteHashLinksDefault(bool $rewrite)

Set default rewrite hash links

from SSViewer
setTemplate(string|array $templates)

No description

from SSViewer
static string
chooseTemplate(array|string $templates)

Find the template to use for a given list

from SSViewer
setParser(TemplateParser $parser)

Set the template parser that will be used in template generation

from SSViewer
getParser()

Returns the parser that is set for template generation

from SSViewer
static bool
hasTemplate(array|string $templates)

Returns true if at least one of the listed templates exists.

from SSViewer
string
exists()

No description

from SSViewer
static string
getTemplateFileByType(string $identifier, string $type = null)

No description

from SSViewer
static 
flush_template_cache(bool $force = false)

Clears all parsed template files in the cache folder.

from SSViewer
static 
flush_cacheblock_cache(bool $force = false)

Clears all partial cache blocks.

from SSViewer
setPartialCacheStore(CacheInterface $cache)

Set the cache object to use when storing / retrieving partial cache blocks.

from SSViewer
CacheInterface
getPartialCacheStore()

Get the cache object to use when storing / retrieving partial cache blocks.

from SSViewer
includeRequirements(bool $incl = true)

Flag whether to include the requirements in this response.

from SSViewer
process(ViewableData $item, array|null $arguments = null, $scope = null)

The process() method handles the "meat" of the template processing.

static string
execute_template(string $template, mixed $data, array $arguments = null, Object $scope = null, bool $globalRequirements = false)

Execute the given template, passing it the given data.

from SSViewer
static string
execute_string(string $content, mixed $data, array $arguments = null, bool $globalRequirements = false)

Execute the evaluated string, passing it the given data.

from SSViewer
string
parseTemplateContent(string $content, string $template = "")

Parse given template contents

from SSViewer
array
templates()

Returns the filenames of the template that will be rendered. It is a map that may contain 'Content' & 'Layout', and will have to contain 'main'

from SSViewer
setTemplateFile(string $type, string $file)

No description

from SSViewer
static string
get_base_tag(string $contentGeneratedSoFar)

Return an appropriate base tag for the given template.

from SSViewer
setCacheTemplate(boolean $cacheTemplate)

No description

boolean
getCacheTemplate()

No description

Details

in Configurable at line 20
static Config_ForClass config()

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

....).

Return Value

Config_ForClass

in Configurable at line 32
mixed stat(string $name) deprecated

deprecated 5.0 Use ->config()->get() instead

Get inherited config value

Parameters

string $name

Return Value

mixed

in Configurable at line 44
mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

in Configurable at line 57
$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

in Injectable at line 26
static Injectable create(array $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'); $list = SiteTree::get();

Parameters

array $args

Return Value

Injectable

in Injectable at line 43
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).

Parameters

string $class Optional classname to create, if the called class should not be used

Return Value

Injectable The singleton instance

at line 38
__construct(string $content, TemplateParser $parser = null)

Parameters

string $content
TemplateParser $parser

in SSViewer at line 222
static flush()

Triggered early in the request when someone requests a flush.

in SSViewer at line 235
static SSViewer fromString(string $content, bool|void $cacheTemplate = null)

Create a template from a string instead of a .ss file

Parameters

string $content The template content
bool|void $cacheTemplate Whether or not to cache the template from string

Return Value

SSViewer

in SSViewer at line 250
static set_themes(array $themes = [])

Assign the list of active themes to apply.

If default themes should be included add $default as the last entry.

Parameters

array $themes

in SSViewer at line 260
static add_themes(array $themes = [])

Add to the list of active themes to apply

Parameters

array $themes

in SSViewer at line 273
static array get_themes()

Get the list of active themes

Return Value

array

in SSViewer at line 302
static set_theme(string $theme) deprecated

deprecated 4.0.0:5.0.0 Use the "SSViewer#set_themes" instead

Parameters

string $theme The "base theme" name (without underscores).

in SSViewer at line 319
static array get_templates_by_class(string|object $classOrObject, string $suffix = '', string $baseClass = null)

Traverses the given the given class context looking for candidate template names which match each item in the class hierarchy. The resulting list of template candidates may or may not exist, but you can invoke {see SSViewer::chooseTemplate} on any list to determine the best candidate based on the current themes.

Parameters

string|object $classOrObject Valid class name, or object
string $suffix
string $baseClass Class to halt ancestry search at

Return Value

array

in SSViewer at line 355
static ViewableData topLevel()

Get the current item being processed

Return Value

ViewableData

Check if rewrite hash links are enabled on this instance

Return Value

bool

Set if hash links are rewritten for this instance

Parameters

bool $rewrite

Return Value

$this

in SSViewer at line 393
static bool getRewriteHashLinksDefault()

Get default value for rewrite hash links for all modules

Return Value

bool

in SSViewer at line 407
static setRewriteHashLinksDefault(bool $rewrite)

Set default rewrite hash links

Parameters

bool $rewrite

in SSViewer at line 415
setTemplate(string|array $templates)

Parameters

string|array $templates

in SSViewer at line 428
static string chooseTemplate(array|string $templates)

Find the template to use for a given list

Parameters

array|string $templates

Return Value

string

in SSViewer at line 438
setParser(TemplateParser $parser)

Set the template parser that will be used in template generation

Parameters

TemplateParser $parser

in SSViewer at line 448
TemplateParser getParser()

Returns the parser that is set for template generation

Return Value

TemplateParser

in SSViewer at line 463
static bool hasTemplate(array|string $templates)

Returns true if at least one of the listed templates exists.

Parameters

array|string $templates

Return Value

bool

in SSViewer at line 482
string exists()

Return Value

string

in SSViewer at line 492
static string getTemplateFileByType(string $identifier, string $type = null)

Parameters

string $identifier A template name without '.ss' extension or path
string $type The template type, either "main", "Includes" or "Layout"

Return Value

string Full system path to a template file

in SSViewer at line 505
static flush_template_cache(bool $force = false)

Clears all parsed template files in the cache folder.

Can only be called once per request (there may be multiple SSViewer instances).

Parameters

bool $force Set this to true to force a re-flush. If left to false, flushing may only be performed once a request.

in SSViewer at line 526
static flush_cacheblock_cache(bool $force = false)

Clears all partial cache blocks.

Can only be called once per request (there may be multiple SSViewer instances).

Parameters

bool $force Set this to true to force a re-flush. If left to false, flushing may only be performed once a request.

in SSViewer at line 542
setPartialCacheStore(CacheInterface $cache)

Set the cache object to use when storing / retrieving partial cache blocks.

Parameters

CacheInterface $cache

in SSViewer at line 552
CacheInterface getPartialCacheStore()

Get the cache object to use when storing / retrieving partial cache blocks.

Return Value

CacheInterface

in SSViewer at line 566
includeRequirements(bool $incl = true)

Flag whether to include the requirements in this response.

Parameters

bool $incl

at line 50
DBHTMLText process(ViewableData $item, array|null $arguments = null, $scope = null)

The process() method handles the "meat" of the template processing.

It takes care of caching the output (via {@link Cache}), as well as replacing the special "$Content" and "$Layout" placeholders with their respective subtemplates.

The method injects extra HTML in the header via {@link Requirements::includeInHTML()}.

Note: You can call this method indirectly by {@link ViewableData->renderWith()}.

Parameters

ViewableData $item
array|null $arguments Arguments to an included template
$scope

Return Value

DBHTMLText Parsed template output.

in SSViewer at line 752
static string execute_template(string $template, mixed $data, array $arguments = null, Object $scope = null, bool $globalRequirements = false)

Execute the given template, passing it the given data.

Used by the <% include %> template tag to process templates.

Parameters

string $template Template name
mixed $data Data context
array $arguments Additional arguments
Object $scope
bool $globalRequirements

Return Value

string Evaluated result

in SSViewer at line 789
static string execute_string(string $content, mixed $data, array $arguments = null, bool $globalRequirements = false)

Execute the evaluated string, passing it the given data.

Used by partial caching to evaluate custom cache keys expressed using template expressions

Parameters

string $content Input string
mixed $data Data context
array $arguments Additional arguments
bool $globalRequirements

Return Value

string Evaluated result

in SSViewer at line 816
string parseTemplateContent(string $content, string $template = "")

Parse given template contents

Parameters

string $content The template contents
string $template The template file name

Return Value

string

in SSViewer at line 831
array templates()

Returns the filenames of the template that will be rendered. It is a map that may contain 'Content' & 'Layout', and will have to contain 'main'

Return Value

array

in SSViewer at line 840
setTemplateFile(string $type, string $file)

Parameters

string $type "Layout" or "main"
string $file Full system path to the template file

in SSViewer at line 857
static string get_base_tag(string $contentGeneratedSoFar)

Return an appropriate base tag for the given template.

It will be closed on an XHTML document, and unclosed on an HTML document.

Parameters

string $contentGeneratedSoFar The content of the template generated so far; it should contain the DOCTYPE declaration.

Return Value

string

at line 80
setCacheTemplate(boolean $cacheTemplate)

Parameters

boolean $cacheTemplate

at line 88
boolean getCacheTemplate()

Return Value

boolean