Views
in package
Views class.
Tags
Table of Contents
Properties
- $Container : Container
- $controllerMethod : string
- $Modules : Modules
Methods
- __construct() : mixed
- Load the views file.
- render() : string
- Render the views file.
- locateViews() : string
- Locate views file.
Properties
$Container
protected
Container
$Container
Tags
$controllerMethod
protected
string
$controllerMethod
The controller class and method that call the views. This is useful in hook. Result example: Rdb\Modules\RdbAdmin\Controllers\Admin\Users\EditController->indexAction
Tags
$Modules
protected
Modules
$Modules
Methods
__construct()
Load the views file.
public
__construct(Container $Container) : mixed
Parameters
- $Container : Container
-
The DI container class.
render()
Render the views file.
public
render(string $viewsFile[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $options = [] ]) : string
Parameters
- $viewsFile : string
-
The views file name. This depend on option
noLocateViews
. If this option was not set or set tofalse
then the views file is locate from "Views" folder in the running module and no need to add ".php" extension. If this option was set totrue
then the views file MUST be full path to the file (.php extension is required). - $data : array<string|int, mixed> = []
-
The data that will becomes variable in views file. Example
['foo' => 'bar'];
will becomesecho $foo; // result is bar.
- $options : array<string|int, mixed> = []
-
The options for render the views.
noLocateViews
Set totrue
to tell that views file is already full path, no need to locate full path to the file.
viewsModule
Set the module folder name to locate views in there.
Return values
string —Return views content.
locateViews()
Locate views file.
protected
locateViews(string $viewsFile[, string $currentModule = null ]) : string
Parameters
- $viewsFile : string
-
The views file name without .php extension.
- $currentModule : string = null
-
The module folder name to locate views in there. Default is null to auto detect current module but auto detect did not work in all case.
Tags
Return values
string —Return full path to views file if the file was found.