ViewFactory
class ViewFactory
View factory.
Traits
Properties
protected string | $path | Path. | |
protected string | $extension | File extension. | from NamespacedFileLoaderTrait |
protected array | $namespaces | Namespaces. | from NamespacedFileLoaderTrait |
protected FileSystem | $fileSystem | File sytem. | |
protected string | $charset | Charset. | |
protected Container | $container | Container. | |
protected array | $renderers | View renderers. | |
protected array | $globalVariables | Global view variables. | |
protected array | $autoAssignVariables | Variables that should be auto assigned to views. | |
protected array | $viewCache | View cache. | |
protected array | $rendererInstances | Renderer instances. |
Methods
Registers a namespace.
Returns the path to the file.
Returns an array of cascading file paths.
Constructor.
Returns the charset.
Sets the charset.
Assign a global view variable that will be available in all views.
Assign variables that should be auto assigned to views upon creation.
Clears the autoassign variables.
Returns an array containing the view path and the renderer we should use.
Returns a renderer instance.
Returns TRUE if the view exists and FALSE if not.
Returns view specific auto assign variables.
Returns auto assign variables for a view.
Returns array where variables have been merged in order of importance.
Creates and returns a rendered view.
Details
in NamespacedFileLoaderTrait at line 49
setPath(string $path)
Sets the default path.
in NamespacedFileLoaderTrait at line 59
setExtension(string $extension)
Sets the extension.
in NamespacedFileLoaderTrait at line 70
registerNamespace(string $namespace, string $path)
Registers a namespace.
in NamespacedFileLoaderTrait at line 83
protected string
getFilePath(string $file, string|null $extension = null, string|null $suffix = null)
Returns the path to the file.
in NamespacedFileLoaderTrait at line 125
protected array
getCascadingFilePaths(string $file, string|null $extension = null, string|null $suffix = null)
Returns an array of cascading file paths.
at line 97
__construct(FileSystem $fileSystem, string $path, string $charset = 'UTF-8', Container|null $container = null)
Constructor.
at line 115
string
getCharset()
Returns the charset.
at line 126
ViewFactory
setCharset(string $charset)
Sets the charset.
at line 140
ViewFactory
extend(string $extension, Closure|string $renderer)
Registers a custom view renderer.
at line 154
ViewFactory
assign(string $name, mixed $value)
Assign a global view variable that will be available in all views.
at line 168
ViewFactory
autoAssign(string $view, callable $variables)
Assign variables that should be auto assigned to views upon creation.
at line 183
ViewFactory
clearAutoAssignVariables()
Clears the autoassign variables.
at line 197
protected array|false
getViewPathAndExtension(string $view, bool $throwException = true)
Returns an array containing the view path and the renderer we should use.
at line 235
protected RendererInterface
rendererFactory(Closure|string $renderer)
Creates a renderer instance.
at line 246
protected RendererInterface
resolveRenderer(string $extension)
Returns a renderer instance.
at line 262
bool
exists(string $view)
Returns TRUE if the view exists and FALSE if not.
at line 273
protected array
getAutoAssignVariablesForView(string $view)
Returns view specific auto assign variables.
at line 289
protected array
getAutoAssignVariables(string $view)
Returns auto assign variables for a view.
at line 301
protected array
mergeVariables(string $view, array $variables)
Returns array where variables have been merged in order of importance.
at line 313
View
create(string $view, array $variables = [])
Creates and returns a view instance.
at line 327
string
render(string $view, array $variables = [])
Creates and returns a rendered view.