TemplateRender
class TemplateRender
Class TemplateRender
Traits
Constants
SKINS_FOLDER |
Folder containing the skins. Each subfolder is a skin (configuration that modifies the visual aspect of the application) Each template will be a folder whose name will be the one that will appear in the template selector. |
TEMPLATES_FOLDER |
Folder containing the different twig templates |
COMMON_TEMPLATES_FOLDER |
Folder that contains templates common to the entire application, but that can be overwritten. |
Properties
static protected bool | $singletonArray | Set to true if you want use more that one singleton using and index param in getInstance | from Singleton |
static protected string | $basePath | The base path where config files are placed. | from Singleton |
static private string | $className | Name of the class | from Singleton |
static private array | $instances | Hold the classes on instance. | from Singleton |
protected bool | $separateConfigFile | Set to true if you want to save configuration in a separate file | from Singleton |
static protected Environment | $twig | The renderer. | |
static protected string|null | $template | The template to use. | |
static protected string|null | $skin | The skin to use. | |
static protected string | $commonTemplatesFolder | Indicates the folder where the files common to all the templates are located. | |
static private string | $currentSkin | It's the name of the skin that is being used. | |
static private string | $templatesFolder | It is the skin, that is, the folder that contains the templates. | |
static private array | $templatesFolders | Array of all templates folders. | |
static private array | $templateVars | Contains the template vars. | |
static private FilesystemLoader | $loader | Template loader from filesystem. |
Methods
Return this instance.
Save config to file.
Return default values
Initialization, equivalent to __construct and must be called from main class.
TemplateRender constructor.
Set a skin.
Establish a new template. The parameter must be only de template name, no the path!
Return the template folder path.
Returns a list of available paths.
Return the common template folder path.
Add additional language folders.
Sets a new twig environment.
Renders a template.
Return the full twig environtment.
Returns a list of options.
Add extensions to skin render.
Load paths, including modules.
Return the assigned template to use.
Return a list of template vars, merged with $vars,
Sets the new template to use.
Returns true if a template has been specified.
Add vars to template vars.
Returns an array with the list of skins (folders inside the folder specified for the templates).
Check different possible locations for the file and return the corresponding URI, if it exists.
Return the template folder path from uri.
Return the common template folder path from uri.
Details
at line 215
static
TemplateRender
getInstance()
Return this instance.
in
Singleton
at line 88
static private string
getClassName()
Returns the class name.
in
Singleton
at line 103
bool
setConfig(array $params, bool $merge = true, string $index = 'main')
Save config to file.
in
Singleton
at line 130
private array
getYamlContent()
Returns the content of the Yaml file.
in
Singleton
at line 152
string
getFilePath()
Return the full file config path.
in
Singleton
at line 162
string
getFileName()
Return the file name.
in
Singleton
at line 172
static string
yamlName()
Return the classname for yaml file.
in
Singleton
at line 184
protected bool
fileExists(string $filename)
Returns if file exists.
in
Singleton
at line 196
array
getConfig(string $index = 'main')
Returns the yaml config params.
at line 225
static array
getDefaultValues()
Return default values
in
Singleton
at line 215
string
getBasePath()
Return the base path.
in
Singleton
at line 223
protected
initSingleton()
Initialization, equivalent to __construct and must be called from main class.
at line 122
__construct()
TemplateRender constructor.
at line 148
setSkin(string $skin)
Set a skin.
at line 162
setTemplatesFolder(string $template)
Establish a new template. The parameter must be only de template name, no the path!
at line 172
string
getTemplatesFolder()
Return the template folder path.
at line 182
array
getPaths()
Returns a list of available paths.
at line 205
string
getCommonTemplatesFolder()
Return the common template folder path.
at line 235
addDirs(array $folders = [])
Add additional language folders.
at line 253
$this
setTwig(Environment $twig)
Sets a new twig environment.
at line 266
string
render(array $data = [])
Renders a template.
at line 291
private Environment
getTwig()
Return the full twig environtment.
at line 304
private array
getOptions()
Returns a list of options.
at line 319
private void
addExtensions()
Add extensions to skin render.
at line 337
private
loadPaths()
Load paths, including modules.
at line 366
string|null
getTemplate()
Return the assigned template to use.
at line 378
private array
getTemplateVars(array $vars = [])
Return a list of template vars, merged with $vars,
at line 390
$this
setTemplate(string|null $template)
Sets the new template to use.
at line 401
bool
hasTemplate()
Returns true if a template has been specified.
at line 411
addVars(array $vars = [])
Add vars to template vars.
at line 421
array
getSkins()
Returns an array with the list of skins (folders inside the folder specified for the templates).
at line 443
string
getResourceUri(string $path)
Check different possible locations for the file and return the corresponding URI, if it exists.
at line 466
string
getTemplatesUri()
Return the template folder path from uri.
at line 476
string
getCommonTemplatesUri()
Return the common template folder path from uri.