Properties

$modelClass

$modelClass : string

This object's primary model class name. Should be a plural form.

CakePHP will not inflect the name.

Example: For an object named 'Comments', the modelClass would be 'Comments'. Plugin classes should use Plugin.Comments style names to correctly load models from the correct plugin.

Type

string

$viewClass

$viewClass : string|null

The name of default View class.

Type

string|null

$viewVars

$viewVars : array

Variables for the view

Type

array

$_eventClass

$_eventClass : string

Default class name for new event objects.

Type

string

$_modelFactories

$_modelFactories : array

A list of overridden model factory functions.

Type

array

$_modelType

$_modelType : string

The model type to use.

Type

string

$_viewBuilder

$_viewBuilder : \Cake\View\ViewBuilder

The view builder instance being used.

Type

\Cake\View\ViewBuilder

$View

$View : \Cake\View\View

Instance of the View created during rendering. Won't be set until after Cell::__toString()/render() is called.

Type

\Cake\View\View

$request

$request : \Cake\Http\ServerRequest

An instance of a Cake\Http\ServerRequest object that contains information about the current request.

This object contains all the information about a request and several methods for reading additional information about the request.

Type

\Cake\Http\ServerRequest

$response

$response : \Cake\Http\Response

An instance of a Response object that contains information about the impending response

Type

\Cake\Http\Response

$action

$action : string

The cell's action to invoke.

Type

string

$args

$args : array

Arguments to pass to cell's action.

Type

array

$_validViewOptions

$_validViewOptions : array

These properties can be set directly on Cell and passed to the View as options.

Type

array

$_validCellOptions

$_validCellOptions : array

List of valid options (constructor's fourth arguments) Override this property in subclasses to whitelist which options you want set as properties in your Cell.

Type

array

$_cache

$_cache : array|boolean

Caching setup.

Type

array|boolean

Methods

eventManager()

eventManager(\Cake\Event\EventManager|null  $eventManager = null) : \Cake\Event\EventManager

Returns the Cake\Event\EventManager manager instance for this object.

You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.

Parameters

\Cake\Event\EventManager|null $eventManager

the eventManager to set

Returns

\Cake\Event\EventManager

getEventManager()

getEventManager() : \Cake\Event\EventManager

Returns the Cake\Event\EventManager manager instance for this object.

You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.

Returns

\Cake\Event\EventManager

setEventManager()

setEventManager(\Cake\Event\EventManager  $eventManager) : $this

Returns the Cake\Event\EventManager manager instance for this object.

You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.

Parameters

\Cake\Event\EventManager $eventManager

the eventManager to set

Returns

$this

dispatchEvent()

dispatchEvent(string  $name, array|null  $data = null, object|null  $subject = null) : \Cake\Event\Event

Wrapper for creating and dispatching events.

Returns a dispatched event.

Parameters

string $name

Name of the event.

array|null $data

Any value you wish to be transported with this event to it can be read by listeners.

object|null $subject

The object that this event applies to ($this by default).

Returns

\Cake\Event\Event

tableLocator()

tableLocator(\Cake\ORM\Locator\LocatorInterface|null  $tableLocator = null) : \Cake\ORM\Locator\LocatorInterface

Sets the table locator.

If no parameters are passed, it will return the currently used locator.

Parameters

\Cake\ORM\Locator\LocatorInterface|null $tableLocator

LocatorInterface instance.

Returns

\Cake\ORM\Locator\LocatorInterface

setTableLocator()

setTableLocator(\Cake\ORM\Locator\LocatorInterface  $tableLocator) : $this

Sets the table locator.

Parameters

\Cake\ORM\Locator\LocatorInterface $tableLocator

LocatorInterface instance.

Returns

$this

loadModel()

loadModel(string|null  $modelClass = null, string|null  $modelType = null) : \Cake\Datasource\RepositoryInterface

Loads and constructs repository objects required by this object

Typically used to load ORM Table objects as required. Can also be used to load other types of repository objects your application uses.

If a repository provider does not return an object a MissingModelException will be thrown.

Parameters

string|null $modelClass

Name of model class to load. Defaults to $this->modelClass

string|null $modelType

The type of repository to load. Defaults to the modelType() value.

Throws

\Cake\Datasource\Exception\MissingModelException

If the model class cannot be found.

\InvalidArgumentException

When using a type that has not been registered.

\UnexpectedValueException

If no model type has been defined

Returns

\Cake\Datasource\RepositoryInterface

The model instance created.

modelFactory()

modelFactory(string  $type, callable  $factory) : void

Override a existing callable to generate repositories of a given type.

Parameters

string $type

The name of the repository type the factory function is for.

callable $factory

The factory function used to create instances.

getModelType()

getModelType() : string

Get the model type to be used by this class

Returns

string

setModelType()

setModelType(string  $modelType) : $this

Set the model type to be used by this class

Parameters

string $modelType

The model type

Returns

$this

modelType()

modelType(string|null  $modelType = null) : string|$this

Set or get the model type to be used by this class

Parameters

string|null $modelType

The model type or null to retrieve the current

Returns

string|$this

viewBuilder()

viewBuilder() : \Cake\View\ViewBuilder

Get the view builder being used.

Returns

\Cake\View\ViewBuilder

createView()

createView(string|null  $viewClass = null) : \Cake\View\View

Constructs the view class instance based on the current configuration.

Parameters

string|null $viewClass

Optional namespaced class name of the View class to instantiate.

Throws

\Cake\View\Exception\MissingViewException

If view class was not found.

Returns

\Cake\View\View

set()

set(string|array  $name, mixed  $value = null) : $this

Saves a variable or an associative array of variables for use inside a template.

Parameters

string|array $name

A string or an array of data.

mixed $value

Value in case $name is a string (which then works as the key). Unused if $name is an associative array, otherwise serves as the values to $name's keys.

Returns

$this

viewOptions()

viewOptions(string|array|null  $options = null, boolean  $merge = true) : array

Get/Set valid view options in the object's _validViewOptions property. The property is created as an empty array if it is not set. If called without any parameters it will return the current list of valid view options. See `createView()`.

Parameters

string|array|null $options

string or array of string to be appended to _validViewOptions.

boolean $merge

Whether to merge with or override existing valid View options. Defaults to true.

Returns

array —

The updated view options as an array.

__construct()

__construct(\Cake\Http\ServerRequest|null  $request = null, \Cake\Http\Response|null  $response = null, \Cake\Event\EventManager|null  $eventManager = null, array  $cellOptions = array()) 

Constructor.

Parameters

\Cake\Http\ServerRequest|null $request

The request to use in the cell.

\Cake\Http\Response|null $response

The response to use in the cell.

\Cake\Event\EventManager|null $eventManager

The eventManager to bind events to.

array $cellOptions

Cell options to apply.

initialize()

initialize() : void

Initialization hook method.

Implement this method to avoid having to overwrite the constructor and calling parent::__construct().

render()

render(string|null  $template = null) : string

Render the cell.

Parameters

string|null $template

Custom template name to render. If not provided (null), the last value will be used. This value is automatically set by CellTrait::cell().

Throws

\Cake\View\Exception\MissingCellViewException

When a MissingTemplateException is raised during rendering.

Returns

string —

The rendered cell.

__toString()

__toString() : string

Magic method.

Starts the rendering process when Cell is echoed.

Note This method will trigger an error when view rendering has a problem. This is because PHP will not allow a __toString() method to throw an exception.

Throws

\Error

Include error details for PHP 7 fatal errors.

Returns

string —

Rendered cell

__get()

__get(string  $name) : mixed

Magic accessor for removed properties.

Parameters

string $name

Property name

Returns

mixed

__set()

__set(string  $name, mixed  $value) : void

Magic setter for removed properties.

Parameters

string $name

Property name.

mixed $value

Value to set.

__debugInfo()

__debugInfo() : array

Debug info.

Returns

array

_setModelClass()

_setModelClass(string  $name) : void

Set the modelClass and modelKey properties based on conventions.

If the properties are already set they will not be overwritten

Parameters

string $name

Class name.

_cacheConfig()

_cacheConfig(string  $action, string|null  $template = null) : array

Generate the cache key to use for this cell.

If the key is undefined, the cell class and action name will be used.

Parameters

string $action

The action invoked.

string|null $template

The name of the template to be rendered.

Returns

array —

The cache configuration.