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.
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 51
setPath(string $path)
Sets the default path.
in NamespacedFileLoaderTrait at line 61
setExtension(string $extension)
Sets the extension.
in NamespacedFileLoaderTrait at line 72
registerNamespace(string $namespace, string $path)
Registers a namespace.
in NamespacedFileLoaderTrait at line 86
protected string
getFilePath(string $file, string|null $extension = null, string|null $suffix = null)
Returns the path to the file.
in NamespacedFileLoaderTrait at line 128
protected array
getCascadingFilePaths(string $file, string|null $extension = null, string|null $suffix = null)
Returns an array of cascading file paths.
at line 99
__construct(FileSystem $fileSystem, string $path, string $charset = 'UTF-8', Container|null $container = null)
Constructor.
at line 117
string
getCharset()
Returns the charset.
at line 128
ViewFactory
setCharset(string $charset)
Sets the charset.
at line 142
ViewFactory
extend(string $extension, string|Closure $renderer)
Registers a custom view renderer.
at line 156
ViewFactory
assign(string $name, mixed $value)
Assign a global view variable that will be available in all views.
at line 170
ViewFactory
autoAssign(string $view, callable $variables)
Assign variables that should be auto assigned to views upon creation.
at line 188
protected array|bool
getViewPathAndExtension(string $view, bool $throwException = true)
Returns an array containing the view path and the renderer we should use.
at line 226
protected RendererInterface
rendererFactory(string|Closure $renderer)
Creates a renderer instance.
at line 237
protected RendererInterface
resolveRenderer(string $extension)
Returns a renderer instance.
at line 253
bool
exists(string $view)
Returns TRUE if the view exists and false if not.
at line 264
protected array
getAutoAssignVariablesForView(string $view)
Returns view specific auto assign variables.
at line 280
protected array
getAutoAssignVariables(string $view)
Returns auto assign variables for a view.
at line 292
protected array
mergeVariables(string $view, array $variables)
Returns array where variables have been merged in order of importance.
at line 304
View
create(string $view, array $variables = [])
Creates and returns a view instance.
at line 318
string
render(string $view, array $variables = [])
Creates and returns a rendered view.