class View extends stdClass

Handles operations related to views and its content.

Constants

private APP_COMPONENT_PATH

The app component path

private APP_LAYOUT_PATH

The app layout path

private APP_VIEW_PATH

The app view path

private APP_WIDGET_PATH

The app widget path

private FRAMEWORK_COMPONENT_PATH

The framework component path

private FRAMEWORK_LAYOUT_PATH

The framework layout path

private FRAMEWORK_VIEW_PATH

The framework view path

Properties

protected $_body

The body

protected $_content

The content

protected $_currentBuffer

The content buffer

protected $_head

The head

protected $_layout

The layout

protected $_outputBuffer

The output buffer

protected $_siteTitle

The site title

protected array $widgets

An array of widgets.

Methods

__construct()

Default constructor.

void
addWidget(string $section, string $viewPath, array $data = [])

Registers a new widget.

void
component(string $component, bool $frameworkComponentPath = false)

Includes a component into a view.

mixed
content(string $type)

The content of the page. The two types are head and body. If necessary, we can implement additional types of content.

void
end()

Sets the end for a particular section of content. When called it takes _outputBuffer, cleans it, and outputs it to the screen. In the absence of a previous call to the start() function a message requesting you to call start() is displayed.

void
render(string $viewName, bool $frameworkViewPath = false, bool $frameworkLayoutPath = false)

Performs render operations for a particular view.

void
renderJsx(string $viewComponent, array $props = [], string $entry = 'resources/js/app.jsx')

Renders a React.js file.

string
renderWidget(string $viewPath, array $data = [])

Renders a single widget view file with given data.

string
renderWidgets(string $slot, array $widgets = [])

Renders widgets for a given section.

void
setLayout(string $path)

Sets the layout for the view.

void
setSiteTitle(string $title)

Setter function for site title of current page.

string
siteTitle()

Getter function for current page's site title.

void
start(string $type)

When called this function establishes the beginning for a section of content. Anything between calls of this function and end() will be included in our view.

Details

at line 57
__construct()

Default constructor.

at line 70
void addWidget(string $section, string $viewPath, array $data = [])

Registers a new widget.

Parameters

string $section

The category for the widget.

string $viewPath

The widget described as parentDirectory.widgetName.

array $data

Any data associated with the widget.

Return Value

void

at line 82
void component(string $component, bool $frameworkComponentPath = false)

Includes a component into a view.

Parameters

string $component

The name of the component.

bool $frameworkComponentPath

Uses path for component inside framework when true.

Return Value

void

at line 101
mixed content(string $type)

The content of the page. The two types are head and body. If necessary, we can implement additional types of content.

Parameters

string $type

The type of content we want to render.

Return Value

mixed

The type of content we want to render. If it is not a known type of content we return false;

at line 113
void end()

Sets the end for a particular section of content. When called it takes _outputBuffer, cleans it, and outputs it to the screen. In the absence of a previous call to the start() function a message requesting you to call start() is displayed.

Return Value

void

at line 131
void render(string $viewName, bool $frameworkViewPath = false, bool $frameworkLayoutPath = false)

Performs render operations for a particular view.

Example input: home/index.

Parameters

string $viewName

The name of the view we want to render.

bool $frameworkViewPath

When true we use built in controllers under Core, otherwise controllers defined by users are utilized.

bool $frameworkLayoutPath

Return Value

void

at line 161
void renderJsx(string $viewComponent, array $props = [], string $entry = 'resources/js/app.jsx')

Renders a React.js file.

Parameters

string $viewComponent

The name of the component.

array $props

The prop to be pass to the component.

string $entry

The entry point for JavaScript.

Return Value

void

at line 184
string renderWidget(string $viewPath, array $data = [])

Renders a single widget view file with given data.

Parameters

string $viewPath

Relative to resources/views/, without .php e.g., 'widgets/dashboard/revenueCard'

array $data

Data to extract into the view.

Return Value

string

Rendered HTML output.

at line 205
string renderWidgets(string $slot, array $widgets = [])

Renders widgets for a given section.

Parameters

string $slot

Widget slot name (e.g., 'dashboard.cards').

array $widgets

All registered widgets (usually $this->widgets or WidgetRegistry::getAll()).

Return Value

string

Rendered HTML for the widget slot.

at line 227
void setLayout(string $path)

Sets the layout for the view.

Parameters

string $path

The path for our view.

Return Value

void

at line 237
void setSiteTitle(string $title)

Setter function for site title of current page.

Parameters

string $title

The site title for a particular page.

Return Value

void

at line 246
string siteTitle()

Getter function for current page's site title.

Return Value

string

The site title for a particular page.

at line 259
void start(string $type)

When called this function establishes the beginning for a section of content. Anything between calls of this function and end() will be included in our view.

Parameters

string $type

The name of the type of content we want to include in our view.

Return Value

void