LayoutTemplateManager View code

A class that manages the storage of CmsLayoutTemplate objects in the database.

This class also supports caching, and sending hooks at various levels

since 2.3
package

CMS

license

GPL

author

Robert Campbell

Methods

__construct(\CMSMS\Database\Connection $db, \cms_cache_driver $driver, \CMSMS\hook_manager $hook_manager, \cms_config $config) 

Constructor

Arguments

\CMSMS\Database\Connection $db

The database

\cms_cache_driver $driver

The Cache driver

\CMSMS\hook_manager $hook_manager

The hook manager

\cms_config $config

template_name_to_id(string $name) : integer|null

Given a template name, generate an id.

This method uses a cached mapping of template names to id. If the item does not exist in the cache, then the cache item is built from the database.

Arguments

string $name

The template name

Response

integer|null

get_default_template_by_type(integer $type_id) : integer|null

Given a type id, return its type id

This method uses a cache that is built from the database if necessary.

Arguments

integer $type_id

Response

integer|null

The default template id, if any.

generate_unique_template_name(string $prototype, string $prefix = null) : string

Generate a unique template name

Arguments

string $prototype

The input prototype

string $prefix

A prefix to apply to all output

Response

string

validate_template(\CmsLayoutTemplate $tpl) 

Validate a template to ensure that it is suitable for storage.

This method throws exceptions if validation cannot be assured.

Arguments

_insert_template(\CmsLayoutTemplate $tpl) : \CmsLayoutTemplate

Insert a template into the database

Arguments

Response

\CmsLayoutTemplate

save_template(\CmsLayoutTemplate $tpl) 

Save a template into the database.

This method takes an existing template object and either updates it into the database, or inserts it.

Arguments

\CmsLayoutTemplate $tpl

The template object.

delete_template(\CmsLayoutTemplate $tpl) 

Delete a template from the database

This method removes a template object from the database and any caches. it does not modify the template object, so care must be taken with the id.

Arguments

load_template(mixed $a) : \CmsLayoutTemplate|null

Load a template

Arguments

mixed $a

The template id or name to load.

Response

\CmsLayoutTemplate|null

load_bulk_templates(array $list) : array<mixed,\CmsLayoutTemplate>

Load multiple templates

Arguments

array $list

An array of integer template ids.

Response

array<mixed,\CmsLayoutTemplate>

load_templates_by_type(\CmsLayoutTemplateType $type) : array<mixed,\CmsLayoutTemplate>

Load all templates of a given type

Arguments

Response

array<mixed,\CmsLayoutTemplate>

get_owned_templates(mixed $a) : array<mixed,\CmsLayoutTemplate>

Get all of the templates owned by a specific user

Arguments

mixed $a

Either the integer uid or the username of a user.

Response

array<mixed,\CmsLayoutTemplate>

get_editable_templates(mixed $a) 

Get all of the templates that a user owns or can otherwise edit.

Arguments

mixed $a

Either the integer uid or a username

load_all_templates_by_type(\CmsLayoutTemplateType $type) : array<mixed,\CmsLayoutTemplate>|null

Given a template type, get all templates

Arguments

Response

array<mixed,\CmsLayoutTemplate>|null

load_default_template_by_type(mixed $t) 

Given a template type, get the default template of that type

Arguments

mixed $t

A type name, a type id, or a CmsLayoutTemplateType object

Properties

db

db : 

Type(s)

cache_driver

cache_driver : 

Type(s)

hook_manager

hook_manager : 

Type(s)

config

config : 

Type(s)