API Documentation for: 1.1.1
Show:

Controller Class

Extends CanteenBase
Namespace: Canteen\Controllers

Handle dynamic content and page requests. Located in the namespace Canteen\Controllers.

Constructor

Controller

(
  • page
  • [dynamicUri='']
)

Parameters:

  • page Page

    The current page object

  • [dynamicUri=''] String optional

    The dynamic URI for which page.isDynamic is true

Methods

addData

(
  • name
  • value
)

Add a data substitution variable

Parameters:

  • name String | Dictionary | Object

    The name of the data variable or an array of (name=>value, name=>value)

  • value Mixed

    The string of the value (optional if setting one data property)

addTitle

(
  • title
  • [separator=.]
)

Prepend to the page title

Parameters:

  • title String

    The title string to prepend

  • [separator=.] String optional

    The title separator, default is a period

getData

() Dictionary

Get the data variables

Returns:

Dictionary:

Data variables for substitution

getPage

() Page

Get the current page object

Returns:

Page:

The updated page object

parse

(
  • content
  • substitutions
)
String protected

Inherited from CanteenBase

Convenience method for parsing content

Parameters:

  • content String

    The string to parse

  • substitutions Dictionary

    The dictionary of tags to replace

Returns:

String:

The parsed string

process

()

Process the controller, all controllers should extend this function

service

(
  • alias
)
Service protected

Inherited from CanteenBase:

Get a service by alias

Parameters:

Returns:

Service:

The service matching the alias

setPage

(
  • page
)

Set the current page

Parameters:

  • page Page

    The page to build with this Controller

template

(
  • name
  • [substitutions=[]
)
String protected

Inherited from CanteenBase:

Convenience method for parsing content

Parameters:

  • name String

    The name of the template to parse

  • [substitutions=[] Dictionary optional

    The dictionary of tags to replace

Returns:

String:

The parsed string

Properties

cache

ServerCache

Inherited from CanteenBase:

Get the instance of the site cache

data

Dictionary protected

Any custom substitutions for the parser

dynamicUri

String protected

For dynamic pages, the extra stuff after the page URI

page

Page protected

The the current page

parser

Parser

Inherited from CanteenBase:

The parser is responsible for rendering templates

profiler

Profiler

Inherited from CanteenBase:

The instance of the profiler for debugging performance

settings

SettingsManager

Inherited from CanteenBase:

Get the instance of the settings manager

site

Site

Inherited from CanteenBase:

Convenience getter for the site

user

Authorization

Inherited from CanteenBase:

Get the Authorization class to handle things like login, password change