CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.2 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.2
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget

Class Cell

Cell base.

Abstract
Namespace: Cake\View

Property Summary

  • $View public deprecated
    Cake\View\View

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

  • $_cache protected
    array|bool

    Caching setup.

  • $_eventClass protected
    string

    Default class name for new event objects.

  • $_eventManager protected
    Cake\Event\EventManager

    Instance of the Cake\Event\EventManager this object is using to dispatch inner events.

  • $_modelFactories protected
    array

    A list of model factory functions.

  • $_modelType protected
    string

    The model type to use.

  • $_tableLocator protected
    Cake\ORM\Locator\LocatorInterface

    Table locator instance

  • $_validCellOptions protected
    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.

  • $_validViewOptions protected
    array

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

  • $_viewBuilder protected
    Cake\View\ViewBuilder

    The view builder instance being used.

  • $action public
    string

    The cell's action to invoke.

  • $args public
    array

    Arguments to pass to cell's action.

  • $helpers public
    array

    The helpers this cell uses.

  • $modelClass public
    string

    This object's primary model class name. Should be a plural form. CakePHP will not inflect the name.

  • $plugin public
    string

    Automatically set to the name of a plugin.

  • $request public
    Cake\Network\Request

    An instance of a Cake\Network\Request 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.

  • $response public
    Cake\Network\Response

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

  • $template public
    string

    Name of the template that will be rendered. This property is inflected from the action name that was invoked.

  • $viewClass public deprecated
    string

    The name of default View class.

  • $viewVars public
    array

    Variables for the view

Method Summary

  • __construct() public

    Constructor.

  • __debugInfo() public

    Debug info.

  • __toString() public

    Magic method.

  • _cacheConfig() protected

    Generate the cache key to use for this cell.

  • _setModelClass() protected

    Set the modelClass and modelKey properties based on conventions.

  • createView() public

    Constructs the view class instance based on the current configuration.

  • dispatchEvent() public

    Wrapper for creating and dispatching events.

  • eventManager() public

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

  • loadModel() public

    Loads and constructs repository objects required by this object

  • modelFactory() public

    Register a callable to generate repositories of a given type.

  • modelType() public

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

  • render() public

    Render the cell.

  • set() public

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

  • tableLocator() public

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

  • viewBuilder() public

    Get the view builder being used.

  • viewOptions() public

    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().

Method Detail

__construct() ¶ public

__construct(Cake\Network\Request|null $request = null, Cake\Network\Response|null $response = null, Cake\Event\EventManager|null $eventManager = null, array $cellOptions = [])

Constructor.

Parameters
Cake\Network\Request|null $request optional

The request to use in the cell.

Cake\Network\Response|null $response optional

The response to use in the cell.

Cake\Event\EventManager|null $eventManager optional

The eventManager to bind events to.

array $cellOptions optional

Cell options to apply.

__debugInfo() ¶ public

__debugInfo(): array

Debug info.

Returns
array

__toString() ¶ public

__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.

Returns
string
Throws
Error
Include error details for PHP 7 fatal errors.

_cacheConfig() ¶ protected

_cacheConfig(string $action): 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.

Returns
array

_setModelClass() ¶ protected

_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.

Returns
void

createView() ¶ public

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

Constructs the view class instance based on the current configuration.

Parameters
string|null $viewClass optional

Optional namespaced class name of the View class to instantiate.

Returns
Cake\View\View
Throws
Cake\View\Exception\MissingViewException
If view class was not found.

dispatchEvent() ¶ public

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 optional

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

object|null $subject optional

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

Returns
Cake\Event\Event

eventManager() ¶ public

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 optional

the eventManager to set

Returns
Cake\Event\EventManager

loadModel() ¶ public

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 optional

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

string|null $modelType optional

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

Returns
Cake\Datasource\RepositoryInterface
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

modelFactory() ¶ public

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

Register a 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.

Returns
void

modelType() ¶ public

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

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

Parameters
string|null $modelType optional

The model type or null to retrieve the current

Returns
string|$this

render() ¶ public

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

Render the cell.

Parameters
string|null $template optional

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

Returns
string
Throws
Cake\View\Exception\MissingCellViewException
When a MissingTemplateException is raised during rendering.

set() ¶ public

set(string|array $name, string|array|null|bool $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.

string|array|null|bool $value optional

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

tableLocator() ¶ public

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 optional

LocatorInterface instance.

Returns
Cake\ORM\Locator\LocatorInterface

viewBuilder() ¶ public

viewBuilder(): Cake\View\ViewBuilder

Get the view builder being used.

Returns
Cake\View\ViewBuilder

viewOptions() ¶ public

viewOptions(string|array|null $options = null, bool $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 optional

string or array of string to be appended to _validViewOptions.

bool $merge optional

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

Returns
array

Property Detail

$View ¶ public deprecated

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

Type
Cake\View\View

$_cache ¶ protected

Caching setup.

Type
array|bool

$_eventClass ¶ protected

Default class name for new event objects.

Type
string

$_eventManager ¶ protected

Instance of the Cake\Event\EventManager this object is using to dispatch inner events.

Type
Cake\Event\EventManager

$_modelFactories ¶ protected

A list of model factory functions.

Type
array

$_modelType ¶ protected

The model type to use.

Type
string

$_tableLocator ¶ protected

Table locator instance

Type
Cake\ORM\Locator\LocatorInterface

$_validCellOptions ¶ protected

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

$_validViewOptions ¶ protected

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

Type
array

$_viewBuilder ¶ protected

The view builder instance being used.

Type
Cake\View\ViewBuilder

$action ¶ public

The cell's action to invoke.

Type
string

$args ¶ public

Arguments to pass to cell's action.

Type
array

$helpers ¶ public

The helpers this cell uses.

This property is copied automatically when using the CellTrait

Type
array

$modelClass ¶ public

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

$plugin ¶ public

Automatically set to the name of a plugin.

Type
string

$request ¶ public

An instance of a Cake\Network\Request 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\Network\Request

$response ¶ public

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

Type
Cake\Network\Response

$template ¶ public

Name of the template that will be rendered. This property is inflected from the action name that was invoked.

Type
string

$viewClass ¶ public deprecated

The name of default View class.

Type
string

$viewVars ¶ public

Variables for the view

Type
array
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs