Overview

Namespaces

  • api
  • config
  • database
  • PHP
  • Slim
    • Exception
    • Http
    • Middleware
  • utiliy

Classes

  • Environment
  • Log
  • LogWriter
  • Middleware
  • Route
  • Router
  • Slim
  • View
  • Overview
  • Namespace
  • Class
  • Tree

Class View

View

The view is responsible for rendering a template. The view should subclass \Slim\View and implement this interface:

public render(string $template);

This method should render the specified template and return the resultant string.

Namespace: Slim
Package: Slim
Author: Josh Lockhart
Since: 1.0.0
Located at thirdparty/Slim/View.php
Methods summary
public
# __construct( )

Constructor

Constructor

This is empty but may be implemented in a subclass

public mixed
# getData( string|null $key = null )

Get data

Get data

Parameters

$key
string|null
$key

Returns

mixed
If key is null, array of template data; If key exists, value of datum with key; If key does not exist, null;
public
# setData( )

Set data

Set data

If two arguments: A single datum with key is assigned value;
$view->setData('color', 'red');

If one argument: Replace all data with provided array keys and values;
$view->setData(array('color' => 'red', 'number' => 1));

Throws

InvalidArgumentException
If incorrect method signature
public
# appendData( array $data )

Append new data to existing template data

Append new data to existing template data

Parameters

$data
array

Throws

InvalidArgumentException
If not given an array argument
public string|null
# getTemplatesDirectory( )

Get templates directory

Get templates directory

Returns

string|null
Path to templates directory without trailing slash; Returns null if templates directory not set;
public
# setTemplatesDirectory( string $dir )

Set templates directory

Set templates directory

Parameters

$dir
string
$dir
public
# setTemplate( string $template )

Set template

Set template

Parameters

$template
string
$template

Throws

RuntimeException
If template file does not exist DEPRECATION WARNING! This method will be removed in the near future.
public
# display( string $template )

Display template

Display template

This method echoes the rendered template to the current output buffer

Parameters

$template
string
$template Pathname of template file relative to templates directoy
public string
# fetch( string $template )

Fetch rendered template

Fetch rendered template

This method returns the rendered template

Parameters

$template
string
$template Pathname of template file relative to templates directory

Returns

string
public string
# render( string $template )

Render template

Render template

Parameters

$template
string
$template Pathname of template file relative to templates directory

Returns

string
DEPRECATION WARNING! Use \Slim\View::fetch to return a rendered template instead of \Slim\View::render.
Properties summary
protected string $templatePath ''
#

Absolute or relative filesystem path to a specific template

DEPRECATION WARNING! This variable will be removed in the near future

Absolute or relative filesystem path to a specific template

DEPRECATION WARNING! This variable will be removed in the near future

protected array $data array()
#

Associative array of template variables

Associative array of template variables

protected string $templatesDirectory
#

Absolute or relative path to the application's templates directory

Absolute or relative path to the application's templates directory

GeoApi API documentation generated by ApiGen 2.8.0