Neuron-PHP

Base
in package

Base view class for the Neuron MVC framework.

This abstract base class provides common functionality for all view types in the MVC framework, including layout management, controller/page tracking, and caching configuration. It serves as the foundation for specific view implementations like HTML, JSON, XML, and Markdown views.

Key features:

  • Layout template management for consistent page structure
  • Controller and page identification for view resolution
  • Individual view caching control (overrides global settings)
  • Fluent interface for method chaining
  • Foundation for multi-format view rendering

The view system supports hierarchical template resolution:

  1. Application-specific view directories
  2. Framework default view templates
  3. Layout wrapping with content injection
Tags
example
// Basic view configuration
$view = new Html();
$view->setLayout('main')
     ->setController('users')
     ->setPage('profile')
     ->setCacheEnabled(true);

// Render view with data
echo $view->render(['user' => $userData]);

Table of Contents

Properties

$fs  : IFileSystem
$_cacheEnabled  : bool|null
$_controller  : string
$_layout  : string
$_page  : string

Methods

__construct()  : mixed
getCacheEnabled()  : bool|null
Get cache enabled setting for this view instance
getController()  : string
getLayout()  : string
getPage()  : string
setCacheEnabled()  : Base
Set cache enabled setting for this view instance
setController()  : Html
setLayout()  : Html
setPage()  : Html

Properties

$_cacheEnabled

private bool|null $_cacheEnabled = null

$_controller

private string $_controller

$_layout

private string $_layout

$_page

private string $_page

Methods

getCacheEnabled()

Get cache enabled setting for this view instance

public getCacheEnabled() : bool|null
Return values
bool|null

null means use global config, true/false overrides global

getController()

public getController() : string
Return values
string

getLayout()

public getLayout() : string
Return values
string

getPage()

public getPage() : string
Return values
string

setCacheEnabled()

Set cache enabled setting for this view instance

public setCacheEnabled(bool|null $cacheEnabled) : Base
Parameters
$cacheEnabled : bool|null

null uses global config, true/false overrides

Return values
Base

setController()

public setController(string $controller) : Html
Parameters
$controller : string
Return values
Html

setLayout()

public setLayout(string $layout) : Html
Parameters
$layout : string
Return values
Html

setPage()

public setPage(string $page) : Html
Parameters
$page : string
Return values
Html

        
On this page

Search results