Cell
in package
Class Cell
A simple class that can call any other class that can be loaded, and echo out it's result. Intended for displaying small blocks of content within views that can be managed by other libraries and not require they are loaded within controller.
Used with the helper function, it's use will look like:
viewCell('\Some\Class::method', 'limit=5 sort=asc', 60, 'cache-name');
Parameters are matched up with the callback method's arguments of the same name:
class Class {
function method($limit, $sort)
}
Alternatively, the params will be passed into the callback method as a simple array if matching params are not found.
class Class {
function method(array $params=null)
}
Table of Contents
- $cache : CacheInterface
- Instance of the current Cache Instance
- __construct() : mixed
- Cell constructor.
- prepareParams() : array<string|int, mixed>|null
- Parses the params attribute. If an array, returns untouched.
- render() : string
- Render a cell, returning its body as a string.
- determineClass() : array<string|int, mixed>
- Given the library string, attempts to determine the class and method to call.
Properties
$cache
Instance of the current Cache Instance
protected
CacheInterface
$cache
Methods
__construct()
Cell constructor.
public
__construct(CacheInterface $cache) : mixed
Parameters
- $cache : CacheInterface
Return values
mixed —prepareParams()
Parses the params attribute. If an array, returns untouched.
public
prepareParams(mixed $params) : array<string|int, mixed>|null
If a string, it should be in the format "key1=value key2=value". It will be split and returned as an array.
Parameters
- $params : mixed
Return values
array<string|int, mixed>|null —render()
Render a cell, returning its body as a string.
public
render(string $library[, null $params = null ], int $ttl[, string|null $cacheName = null ]) : string
Parameters
- $library : string
- $params : null = null
- $ttl : int
- $cacheName : string|null = null
Tags
Return values
string —determineClass()
Given the library string, attempts to determine the class and method to call.
protected
determineClass(string $library) : array<string|int, mixed>
Parameters
- $library : string