<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* Cell base.
*
*/
class Cell {
/**
* Instance of the View created during rendering. Won't be set until after
* Cell::__toString() is called.
*
* @var \Cake\View\View
*/
public $View;
/**
* Name of the action that was invoked.
*
* Action name will be inflected to get the template name when rendering.
*
* @var string
*/
public $action;
/**
* Rendering method.
*
* @param string $action Custom template name to render. If not provided (null), the last
* value will be used. This value is automatically set by `CellTrait::cell()`.
* @return void
*/
public function render($action = null) {
if ($action !== null) {
$this->action = $action;
}
return $this->__toString();
}
/**
* Magic method.
*
* Starts the rendering process when Cell is echoed.
*
* @return string Rendered cell
*/
public function __toString() {
return $this->bla('action');
}
public function bla($action) {
throw new Exception('Not allowed');
}
}
$cell = new Cell();
echo $cell;
Fatal error: Uncaught Exception: Not allowed in /in/W22VR:66
Stack trace:
#0 /in/W22VR(62): Cell->bla('action')
#1 /in/W22VR(71): Cell->__toString()
#2 {main}
thrown in /in/W22VR on line 66
Process exited with code 255.
Fatal error: Method Cell::__toString() must not throw an exception in /in/W22VR on line 71
Process exited with code 255.
Output for 5.0.5, 5.1.0 - 5.1.6
Fatal error: Uncaught exception 'Exception' with message 'Not allowed' in /in/W22VR:66
Stack trace:
#0 /in/W22VR(62): Cell->bla('action')
#1 /in/W22VR(71): Cell->__toString()
#2 {main}
thrown in /in/W22VR on line 66
Process exited with code 255.
Output for 5.0.3 - 5.0.4
Fatal error: Uncaught exception 'Exception' with message 'Not allowed' in /in/W22VR:66
Stack trace:
#0 /in/W22VR(66): Cell::bla()
#1 /in/W22VR(62): Cell->bla('action')
#2 /in/W22VR(71): Cell->__toString()
#3 /in/W22VR(71): unknown()
#4 {main}
thrown in /in/W22VR on line 66
Process exited with code 255.
Output for 5.0.0 - 5.0.2
Fatal error: Uncaught exception 'Exception' with message 'Not allowed' in /in/W22VR:66
Stack trace:
#0 /in/W22VR(62): Cell->bla('action')
#1 /in/W22VR(71): Cell->__toString()
#2 /in/W22VR(71): unknown()
#3 {main}
thrown in /in/W22VR on line 66
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/W22VR on line 28
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/W22VR on line 28
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/W22VR on line 28
Process exited with code 255.