class factory implements cache_interface

Creates s9e\TextFormatter objects

Properties

$link_helper
protected driver_interface $cache
protected string $cache_dir
protected string $cache_key_parser
protected string $cache_key_renderer
protected config $config
protected array $custom_tokens
protected data_access $data_access
protected array $default_definitions
protected array $default_templates
protected dispatcher_interface $dispatcher
protected log_interface $log

Methods

__construct(data_access $data_access, driver_interface $cache, dispatcher_interface $dispatcher, config $config, link_helper $link_helper, log_interface $log, string $cache_dir, string $cache_key_parser, string $cache_key_renderer)

Constructor

invalidate()

Invalidate and/or regenerate this text formatter's cache(s)

tidy()

Tidy/prune this text formatter's cache(s)

Configurator
get_configurator()

Generate and return a new configured instance of s9e\TextFormatter\Configurator

array
regenerate()

Regenerate and cache a new parser and renderer

void
add_bbcode(Configurator $configurator, string $usage, string $template)

Add a BBCode to given configurator

void
configure_autolink(Configurator $configurator)

Configure the Autolink / Autoemail plugins used to linkify text

string
escape_html_attribute(string $value)

Escape a literal to be used in an HTML attribute in an XSL template

array
get_default_bbcodes($configurator)

Return the default BBCodes configuration

array
extract_templates(string $template)

Extract and recompose individual BBCode templates from a style's template file

string
merge_templates(array $style_templates)

Merge the templates from any number of styles into one BBCode template

Details

at line 171
__construct(data_access $data_access, driver_interface $cache, dispatcher_interface $dispatcher, config $config, link_helper $link_helper, log_interface $log, string $cache_dir, string $cache_key_parser, string $cache_key_renderer)

Constructor

Parameters

data_access $data_access
driver_interface $cache
dispatcher_interface $dispatcher
config $config
link_helper $link_helper
log_interface $log
string $cache_dir

Path to the cache dir

string $cache_key_parser

Cache key used for the parser

string $cache_key_renderer

Cache key used for the renderer

at line 187
invalidate()

Invalidate and/or regenerate this text formatter's cache(s)

at line 197
tidy()

Tidy/prune this text formatter's cache(s)

at line 218
Configurator get_configurator()

Generate and return a new configured instance of s9e\TextFormatter\Configurator

Return Value

Configurator

at line 382
array regenerate()

Regenerate and cache a new parser and renderer

Return Value

array

Associative array with at least two elements: "parser" and "renderer"

at line 431
protected void add_bbcode(Configurator $configurator, string $usage, string $template)

Add a BBCode to given configurator

Parameters

Configurator $configurator
string $usage
string $template

Return Value

void

Configure the Autolink / Autoemail plugins used to linkify text

Parameters

Configurator $configurator

Return Value

void

at line 499
protected string escape_html_attribute(string $value)

Escape a literal to be used in an HTML attribute in an XSL template

Escapes "HTML special chars" for obvious reasons and curly braces to avoid them being interpreted as an attribute value template

Parameters

string $value

Original string

Return Value

string

Escaped string

at line 509
protected array get_default_bbcodes($configurator)

Return the default BBCodes configuration

Parameters

$configurator

Return Value

array

2D array. Each element has a 'usage' key, a 'template' key, and an optional 'options' key

at line 564
protected array extract_templates(string $template)

Extract and recompose individual BBCode templates from a style's template file

Parameters

string $template

Style template (bbcode.html)

Return Value

array

Associative array matching BBCode names to their template

at line 645
protected string merge_templates(array $style_templates)

Merge the templates from any number of styles into one BBCode template

When multiple templates are available for the same BBCode (because of multiple styles) we merge them into a single template that uses an xsl:choose construct that determines which style to use at rendering time.

Parameters

array $style_templates

Associative array matching style_ids to their template

Return Value

string