On this page
Class Cell
Cell base.
- Cake\View\Cell uses Cake\Event\EventDispatcherTrait, Cake\ORM\Locator\LocatorAwareTrait, Cake\Datasource\ModelAwareTrait, Cake\View\ViewVarsTrait
Method Detail
__constructsource public
__construct( Cake\Network\Request $request null , Cake\Network\Response $response null , Cake\Event\EventManager $eventManager null , array $cellOptions [] )Constructor.
Parameters
- Cake\Network\Request- $requestoptional null
- The request to use in the cell.
- Cake\Network\Response- $responseoptional null
- The response to use in the cell.
- Cake\Event\EventManager- $eventManageroptional null
- The eventManager to bind events to.
- 
     array $cellOptionsoptional []
- Cell options to apply.
__toStringsource public
__toString( )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
stringRendered cell
_cacheConfigsource protected
_cacheConfig( string $template )Generate the cache key to use for this cell.
If the key is undefined, the cell class and template will be used.
Parameters
- 
     string $template
- The template being rendered.
Returns
arrayThe cache configuration.
rendersource public
render( string|null $template null )Render the cell.
Parameters
- 
     string|null $templateoptional null
- 
     Custom template name to render. If not provided (null), the last value will be used. This value is automatically set by CellTrait::cell().
Returns
stringThe rendered cell.
Throws
Cake\View\Exception\MissingCellViewExceptionWhen a MissingTemplateException is raised during rendering.
Methods used from Cake\Event\EventDispatcherTrait
dispatchEventsource public
dispatchEvent( string $name , array|null $data null , object|null $subject null )Wrapper for creating and dispatching events.
Returns a dispatched event.
Parameters
- 
     string $name
- Name of the event.
- 
     array|null $dataoptional null
- Any value you wish to be transported with this event to it can be read by listeners.
- 
     object|null $subjectoptional null
- The object that this event applies to ($this by default).
Returns
Cake\Event\Event\Cake\Event\Event
eventManagersource public
eventManager( Cake\Event\EventManager $eventManager null )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- $eventManageroptional null
- the eventManager to set
Returns
Cake\Event\EventManager\Cake\Event\EventManager
Methods used from Cake\ORM\Locator\LocatorAwareTrait
tableLocatorsource public
tableLocator( Cake\ORM\Locator\LocatorInterface $tableLocator null )Sets the table locator. If no parameters are passed, it will return the currently used locator.
Parameters
- Cake\ORM\Locator\LocatorInterface- $tableLocatoroptional null
- LocatorInterface instance.
Returns
Cake\ORM\Locator\LocatorInterface\Cake\ORM\Locator\LocatorInterface
Methods used from Cake\Datasource\ModelAwareTrait
_setModelClasssource protected
_setModelClass( string $name )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.
loadModelsource public
loadModel( string|null $modelClass null , string|null $modelType null )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 $modelClassoptional null
- Name of model class to load. Defaults to $this->modelClass
- 
     string|null $modelTypeoptional null
- The type of repository to load. Defaults to the modelType() value.
Returns
objectThe model instance created.
Throws
Cake\Datasource\Exception\MissingModelExceptionIf the model class cannot be found.
InvalidArgumentExceptionWhen using a type that has not been registered.
UnexpectedValueExceptionIf no model type has been defined
modelFactorysource public
modelFactory( string $type , callable $factory )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.
modelTypesource public
modelType( string|null $modelType null )Set or get the model type to be used by this class
Parameters
- 
     string|null $modelTypeoptional null
- The model type or null to retrieve the current
Returns
string|$this$this
Methods used from Cake\View\ViewVarsTrait
createViewsource public
createView( string|null $viewClass null )Constructs the view class instance based on the current configuration.
Parameters
- 
     string|null $viewClassoptional null
- Optional namespaced class name of the View class to instantiate.
Returns
Cake\View\View\Cake\View\View
Throws
Cake\View\Exception\MissingViewExceptionIf view class was not found.
setsource public
set( string|array $name , string|array|null|boolean $value null )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|boolean $valueoptional null
- 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
mixed$this
viewBuildersource public
viewBuilder( )Get the view builder being used.
Returns
Cake\View\ViewBuilder\Cake\View\ViewBuilder
viewOptionssource public
viewOptions( string|array|null $options null , boolean $merge true )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 $optionsoptional null
- string or array of string to be appended to _validViewOptions.
- 
     boolean $mergeoptional true
- 
     Whether to merge with or override existing valid View options. Defaults to true.
Returns
arrayThe updated view options as an array.
Properties summary
$Viewsource
public Cake\View\View
Instance of the View created during rendering. Won't be set until after Cell::__toString() is called.
Deprecated
3.1.0 Use createView() instead.$_validCellOptionssource
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.
[]$_validViewOptionssource
protected array
These properties can be set directly on Cell and passed to the View as options.
See
Cake\View\View[
    'viewPath'
]$helperssource
public array
The helpers this cell uses.
This property is copied automatically when using the CellTrait
[]$requestsource
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.
$responsesource
public Cake\Network\Response
An instance of a Response object that contains information about the impending response
$templatesource
public string
Name of the template that will be rendered. This property is inflected from the action name that was invoked.
Properties used from Cake\Event\EventDispatcherTrait
$_eventManagersource
protected Cake\Event\EventManager
Instance of the Cake\Event\EventManager this object is using to dispatch inner events.
nullProperties used from Cake\ORM\Locator\LocatorAwareTrait
Properties used from Cake\Datasource\ModelAwareTrait
$modelClasssource
public 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.
Properties used from Cake\View\ViewVarsTrait
$viewClasssource
public string
The name of default View class.
Deprecated
3.1.0 Use$this->viewBuilder()->className() instead.null© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
 http://api.cakephp.org/3.1/class-Cake.View.Cell.html