Controller.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP(tm) Project
  12. * @since 0.2.9
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Controller;
  16. use Cake\Controller\Exception\MissingActionException;
  17. use Cake\Datasource\ModelAwareTrait;
  18. use Cake\Event\Event;
  19. use Cake\Event\EventListenerInterface;
  20. use Cake\Event\EventManagerTrait;
  21. use Cake\Log\LogTrait;
  22. use Cake\Network\Request;
  23. use Cake\Network\Response;
  24. use Cake\ORM\TableRegistry;
  25. use Cake\Routing\RequestActionTrait;
  26. use Cake\Routing\Router;
  27. use Cake\Utility\Inflector;
  28. use Cake\Utility\MergeVariablesTrait;
  29. use Cake\View\ViewVarsTrait;
  30. use LogicException;
  31. use ReflectionException;
  32. use ReflectionMethod;
  33. /**
  34. * Application controller class for organization of business logic.
  35. * Provides basic functionality, such as rendering views inside layouts,
  36. * automatic model availability, redirection, callbacks, and more.
  37. *
  38. * Controllers should provide a number of 'action' methods. These are public
  39. * methods on a controller that are not inherited from `Controller`.
  40. * Each action serves as an endpoint for performing a specific action on a
  41. * resource or collection of resources. For example adding or editing a new
  42. * object, or listing a set of objects.
  43. *
  44. * You can access request parameters, using `$this->request`. The request object
  45. * contains all the POST, GET and FILES that were part of the request.
  46. *
  47. * After performing the required action, controllers are responsible for
  48. * creating a response. This usually takes the form of a generated `View`, or
  49. * possibly a redirection to another URL. In either case `$this->response`
  50. * allows you to manipulate all aspects of the response.
  51. *
  52. * Controllers are created by `Dispatcher` based on request parameters and
  53. * routing. By default controllers and actions use conventional names.
  54. * For example `/posts/index` maps to `PostsController::index()`. You can re-map
  55. * URLs using Router::connect() or RouterBuilder::connect().
  56. *
  57. * ### Life cycle callbacks
  58. *
  59. * CakePHP fires a number of life cycle callbacks during each request.
  60. * By implementing a method you can receive the related events. The available
  61. * callbacks are:
  62. *
  63. * - `beforeFilter(Event $event)`
  64. * Called before each action. This is a good place to do general logic that
  65. * applies to all actions.
  66. * - `beforeRender(Event $event)`
  67. * Called before the view is rendered.
  68. * - `beforeRedirect(Event $event, $url, Response $response)`
  69. * Called before a redirect is done.
  70. * - `afterFilter(Event $event)`
  71. * Called after each action is complete and after the view is rendered.
  72. *
  73. * @property \Cake\Controller\Component\AuthComponent $Auth
  74. * @property \Cake\Controller\Component\CookieComponent $Cookie
  75. * @property \Cake\Controller\Component\CsrfComponent $Csrf
  76. * @property \Cake\Controller\Component\FlashComponent $Flash
  77. * @property \Cake\Controller\Component\PaginatorComponent $Paginator
  78. * @property \Cake\Controller\Component\RequestHandlerComponent $RequestHandler
  79. * @property \Cake\Controller\Component\SecurityComponent $Security
  80. * @link http://book.cakephp.org/3.0/en/controllers.html
  81. */
  82. class Controller implements EventListenerInterface
  83. {
  84. use EventManagerTrait;
  85. use LogTrait;
  86. use MergeVariablesTrait;
  87. use ModelAwareTrait;
  88. use RequestActionTrait;
  89. use ViewVarsTrait;
  90. /**
  91. * The name of this controller. Controller names are plural, named after the model they manipulate.
  92. *
  93. * Set automatically using conventions in Controller::__construct().
  94. *
  95. * @var string
  96. */
  97. public $name = null;
  98. /**
  99. * An array containing the names of helpers this controller uses. The array elements should
  100. * not contain the "Helper" part of the class name.
  101. *
  102. * Example: `public $helpers = ['Form', 'Html', 'Time'];`
  103. *
  104. * @var mixed
  105. * @link http://book.cakephp.org/3.0/en/controllers.html#configuring-helpers-to-load
  106. */
  107. public $helpers = [];
  108. /**
  109. * An instance of a Cake\Network\Request object that contains information about the current request.
  110. * This object contains all the information about a request and several methods for reading
  111. * additional information about the request.
  112. *
  113. * @var \Cake\Network\Request
  114. * @link http://book.cakephp.org/3.0/en/controllers/request-response.html#request
  115. */
  116. public $request;
  117. /**
  118. * An instance of a Response object that contains information about the impending response
  119. *
  120. * @var \Cake\Network\Response
  121. * @link http://book.cakephp.org/3.0/en/controllers/request-response.html#response
  122. */
  123. public $response;
  124. /**
  125. * The class name to use for creating the response object.
  126. *
  127. * @var string
  128. */
  129. protected $_responseClass = 'Cake\Network\Response';
  130. /**
  131. * Settings for pagination.
  132. *
  133. * Used to pre-configure pagination preferences for the various
  134. * tables your controller will be paginating.
  135. *
  136. * @var array
  137. * @see \Cake\Controller\Component\PaginatorComponent
  138. */
  139. public $paginate = [];
  140. /**
  141. * Set to true to automatically render the view
  142. * after action logic.
  143. *
  144. * @var bool
  145. */
  146. public $autoRender = true;
  147. /**
  148. * Instance of ComponentRegistry used to create Components
  149. *
  150. * @var \Cake\Controller\ComponentRegistry
  151. */
  152. protected $_components = null;
  153. /**
  154. * Array containing the names of components this controller uses. Component names
  155. * should not contain the "Component" portion of the class name.
  156. *
  157. * Example: `public $components = ['Session', 'RequestHandler', 'Acl'];`
  158. *
  159. * @var array
  160. * @link http://book.cakephp.org/3.0/en/controllers/components.html
  161. */
  162. public $components = [];
  163. /**
  164. * The name of the View class this controller sends output to.
  165. *
  166. * @var string
  167. */
  168. public $viewClass = null;
  169. /**
  170. * The path to this controllers view templates.
  171. * Example `Articles`
  172. *
  173. * Set automatically using conventions in Controller::__construct().
  174. *
  175. * @var string
  176. */
  177. public $viewPath;
  178. /**
  179. * The name of the view file to render. The name specified
  180. * is the filename in /app/Template/<SubFolder> without the .ctp extension.
  181. *
  182. * @var string
  183. */
  184. public $view = null;
  185. /**
  186. * Instance of the View created during rendering. Won't be set until after
  187. * Controller::render() is called.
  188. *
  189. * @var \Cake\View\View
  190. */
  191. public $View;
  192. /**
  193. * These Controller properties will be passed from the Controller to the View as options.
  194. *
  195. * @var array
  196. * @see \Cake\View\View
  197. */
  198. protected $_validViewOptions = [
  199. 'viewVars', 'autoLayout', 'helpers', 'view', 'layout', 'name', 'theme', 'layoutPath',
  200. 'viewPath', 'plugin', 'passedArgs'
  201. ];
  202. /**
  203. * Automatically set to the name of a plugin.
  204. *
  205. * @var string
  206. */
  207. public $plugin = null;
  208. /**
  209. * Holds all passed params.
  210. *
  211. * @var mixed
  212. */
  213. public $passedArgs = [];
  214. /**
  215. * Constructor.
  216. *
  217. * Sets a number of properties based on conventions if they are empty. To override the
  218. * conventions CakePHP uses you can define properties in your class declaration.
  219. *
  220. * @param \Cake\Network\Request|null $request Request object for this controller. Can be null for testing,
  221. * but expect that features that use the request parameters will not work.
  222. * @param \Cake\Network\Response|null $response Response object for this controller.
  223. * @param string|null $name Override the name useful in testing when using mocks.
  224. * @param \Cake\Event\EventManager|null $eventManager The event manager. Defaults to a new instance.
  225. */
  226. public function __construct(Request $request = null, Response $response = null, $name = null, $eventManager = null)
  227. {
  228. if ($this->name === null && $name === null) {
  229. list(, $name) = namespaceSplit(get_class($this));
  230. $name = substr($name, 0, -10);
  231. }
  232. if ($name !== null) {
  233. $this->name = $name;
  234. }
  235. if (!$this->viewPath) {
  236. $viewPath = $this->name;
  237. if (isset($request->params['prefix'])) {
  238. $prefixes = array_map(
  239. 'Cake\Utility\Inflector::camelize',
  240. explode('/', $request->params['prefix'])
  241. );
  242. $viewPath = implode(DS, $prefixes) . DS . $viewPath;
  243. }
  244. $this->viewPath = $viewPath;
  245. }
  246. if (!($request instanceof Request)) {
  247. $request = new Request();
  248. }
  249. $this->setRequest($request);
  250. if (!($response instanceof Response)) {
  251. $response = new Response();
  252. }
  253. $this->response = $response;
  254. if ($eventManager) {
  255. $this->eventManager($eventManager);
  256. }
  257. $this->modelFactory('Table', ['Cake\ORM\TableRegistry', 'get']);
  258. $modelClass = ($this->plugin ? $this->plugin . '.' : '') . $this->name;
  259. $this->_setModelClass($modelClass);
  260. $this->initialize();
  261. $this->_mergeControllerVars();
  262. $this->_loadComponents();
  263. $this->eventManager()->attach($this);
  264. }
  265. /**
  266. * Initialization hook method.
  267. *
  268. * Implement this method to avoid having to overwrite
  269. * the constructor and call parent.
  270. *
  271. * @return void
  272. */
  273. public function initialize()
  274. {
  275. }
  276. /**
  277. * Get the component registry for this controller.
  278. *
  279. * @return \Cake\Controller\ComponentRegistry
  280. */
  281. public function components()
  282. {
  283. if ($this->_components === null) {
  284. $this->_components = new ComponentRegistry($this);
  285. }
  286. return $this->_components;
  287. }
  288. /**
  289. * Add a component to the controller's registry.
  290. *
  291. * This method will also set the component to a property.
  292. * For example:
  293. *
  294. * `$this->loadComponent('Acl.Acl');`
  295. *
  296. * Will result in a `Toolbar` property being set.
  297. *
  298. * @param string $name The name of the component to load.
  299. * @param array $config The config for the component.
  300. * @return \Cake\Controller\Component
  301. */
  302. public function loadComponent($name, array $config = [])
  303. {
  304. list(, $prop) = pluginSplit($name);
  305. $this->{$prop} = $this->components()->load($name, $config);
  306. return $this->{$prop};
  307. }
  308. /**
  309. * Magic accessor for model autoloading.
  310. *
  311. * @param string $name Property name
  312. * @return bool|object The model instance or false
  313. */
  314. public function __get($name)
  315. {
  316. list($plugin, $class) = pluginSplit($this->modelClass, true);
  317. if ($class !== $name) {
  318. return false;
  319. }
  320. return $this->loadModel($plugin . $class);
  321. }
  322. /**
  323. * Sets the request objects and configures a number of controller properties
  324. * based on the contents of the request. Controller acts as a proxy for certain View variables
  325. * which must also be updated here. The properties that get set are:
  326. *
  327. * - $this->request - To the $request parameter
  328. * - $this->plugin - To the $request->params['plugin']
  329. * - $this->autoRender - To false if $request->params['return'] == 1
  330. * - $this->passedArgs - The combined results of params['named'] and params['pass]
  331. * - View::$passedArgs - $this->passedArgs
  332. * - View::$plugin - $this->plugin
  333. * - View::$view - To the $request->params['action']
  334. * - View::$autoLayout - To the false if $request->params['bare']; is set.
  335. *
  336. * @param \Cake\Network\Request $request Request instance.
  337. * @return void
  338. */
  339. public function setRequest(Request $request)
  340. {
  341. $this->request = $request;
  342. $this->plugin = isset($request->params['plugin']) ? $request->params['plugin'] : null;
  343. $this->view = isset($request->params['action']) ? $request->params['action'] : null;
  344. if (isset($request->params['pass'])) {
  345. $this->passedArgs = $request->params['pass'];
  346. }
  347. }
  348. /**
  349. * Dispatches the controller action. Checks that the action
  350. * exists and isn't private.
  351. *
  352. * @return mixed The resulting response.
  353. * @throws \LogicException When request is not set.
  354. * @throws \Cake\Controller\Exception\MissingActionException When actions are not defined or inaccessible.
  355. */
  356. public function invokeAction()
  357. {
  358. $request = $this->request;
  359. if (!isset($request)) {
  360. throw new LogicException('No Request object configured. Cannot invoke action');
  361. }
  362. if (!$this->isAction($request->params['action'])) {
  363. throw new MissingActionException([
  364. 'controller' => $this->name . "Controller",
  365. 'action' => $request->params['action'],
  366. 'prefix' => isset($request->params['prefix']) ? $request->params['prefix'] : '',
  367. 'plugin' => $request->params['plugin'],
  368. ]);
  369. }
  370. $callable = [$this, $request->params['action']];
  371. return call_user_func_array($callable, $request->params['pass']);
  372. }
  373. /**
  374. * Merge components, helpers vars from
  375. * parent classes.
  376. *
  377. * @return void
  378. */
  379. protected function _mergeControllerVars()
  380. {
  381. $this->_mergeVars(
  382. ['components', 'helpers'],
  383. ['associative' => ['components', 'helpers']]
  384. );
  385. }
  386. /**
  387. * Returns a list of all events that will fire in the controller during its lifecycle.
  388. * You can override this function to add you own listener callbacks
  389. *
  390. * @return array
  391. */
  392. public function implementedEvents()
  393. {
  394. return [
  395. 'Controller.initialize' => 'beforeFilter',
  396. 'Controller.beforeRender' => 'beforeRender',
  397. 'Controller.beforeRedirect' => 'beforeRedirect',
  398. 'Controller.shutdown' => 'afterFilter',
  399. ];
  400. }
  401. /**
  402. * Loads the defined components using the Component factory.
  403. *
  404. * @return void
  405. */
  406. protected function _loadComponents()
  407. {
  408. if (empty($this->components)) {
  409. return;
  410. }
  411. $registry = $this->components();
  412. $components = $registry->normalizeArray($this->components);
  413. foreach ($components as $properties) {
  414. $this->loadComponent($properties['class'], $properties['config']);
  415. }
  416. }
  417. /**
  418. * Perform the startup process for this controller.
  419. * Fire the Components and Controller callbacks in the correct order.
  420. *
  421. * - Initializes components, which fires their `initialize` callback
  422. * - Calls the controller `beforeFilter`.
  423. * - triggers Component `startup` methods.
  424. *
  425. * @return void|\Cake\Network\Response
  426. */
  427. public function startupProcess()
  428. {
  429. $event = $this->dispatchEvent('Controller.initialize');
  430. if ($event->result instanceof Response) {
  431. return $event->result;
  432. }
  433. $event = $this->dispatchEvent('Controller.startup');
  434. if ($event->result instanceof Response) {
  435. return $event->result;
  436. }
  437. }
  438. /**
  439. * Perform the various shutdown processes for this controller.
  440. * Fire the Components and Controller callbacks in the correct order.
  441. *
  442. * - triggers the component `shutdown` callback.
  443. * - calls the Controller's `afterFilter` method.
  444. *
  445. * @return void|\Cake\Network\Response
  446. */
  447. public function shutdownProcess()
  448. {
  449. $event = $this->dispatchEvent('Controller.shutdown');
  450. if ($event->result instanceof Response) {
  451. return $event->result;
  452. }
  453. }
  454. /**
  455. * Redirects to given $url, after turning off $this->autoRender.
  456. * Script execution is halted after the redirect.
  457. *
  458. * @param string|array $url A string or array-based URL pointing to another location within the app,
  459. * or an absolute URL
  460. * @param int $status HTTP status code (eg: 301)
  461. * @return void|\Cake\Network\Response
  462. * @link http://book.cakephp.org/3.0/en/controllers.html#Controller::redirect
  463. */
  464. public function redirect($url, $status = 302)
  465. {
  466. $this->autoRender = false;
  467. $response = $this->response;
  468. if ($status) {
  469. $response->statusCode($status);
  470. }
  471. $event = $this->dispatchEvent('Controller.beforeRedirect', [$url, $response]);
  472. if ($event->result instanceof Response) {
  473. return $event->result;
  474. }
  475. if ($event->isStopped()) {
  476. return;
  477. }
  478. if ($url !== null && !$response->location()) {
  479. $response->location(Router::url($url, true));
  480. }
  481. return $response;
  482. }
  483. /**
  484. * Internally redirects one action to another. Does not perform another HTTP request unlike Controller::redirect()
  485. *
  486. * Examples:
  487. *
  488. * ```
  489. * setAction('another_action');
  490. * setAction('action_with_parameters', $parameter1);
  491. * ```
  492. *
  493. * @param string $action The new action to be 'redirected' to.
  494. * Any other parameters passed to this method will be passed as parameters to the new action.
  495. * @return mixed Returns the return value of the called action
  496. */
  497. public function setAction($action)
  498. {
  499. $this->request->params['action'] = $action;
  500. $this->view = $action;
  501. $args = func_get_args();
  502. unset($args[0]);
  503. return call_user_func_array([&$this, $action], $args);
  504. }
  505. /**
  506. * Instantiates the correct view class, hands it its data, and uses it to render the view output.
  507. *
  508. * @param string $view View to use for rendering
  509. * @param string $layout Layout to use
  510. * @return \Cake\Network\Response A response object containing the rendered view.
  511. * @link http://book.cakephp.org/3.0/en/controllers.html#rendering-a-view
  512. */
  513. public function render($view = null, $layout = null)
  514. {
  515. if (!empty($this->request->params['bare'])) {
  516. $this->getView()->autoLayout = false;
  517. }
  518. $event = $this->dispatchEvent('Controller.beforeRender');
  519. if ($event->result instanceof Response) {
  520. $this->autoRender = false;
  521. return $event->result;
  522. }
  523. if ($event->isStopped()) {
  524. $this->autoRender = false;
  525. return $this->response;
  526. }
  527. $this->autoRender = false;
  528. $this->response->body($this->getView()->render($view, $layout));
  529. return $this->response;
  530. }
  531. /**
  532. * Returns the referring URL for this request.
  533. *
  534. * @param string|null $default Default URL to use if HTTP_REFERER cannot be read from headers
  535. * @param bool $local If true, restrict referring URLs to local server
  536. * @return string Referring URL
  537. */
  538. public function referer($default = null, $local = false)
  539. {
  540. if (!$this->request) {
  541. return Router::url($default, !$local);
  542. }
  543. $referer = $this->request->referer($local);
  544. if ($referer === '/' && $default && $default !== $referer) {
  545. return Router::url($default, !$local);
  546. }
  547. return $referer;
  548. }
  549. /**
  550. * Handles pagination of records in Table objects.
  551. *
  552. * Will load the referenced Table object, and have the PaginatorComponent
  553. * paginate the query using the request date and settings defined in `$this->paginate`.
  554. *
  555. * This method will also make the PaginatorHelper available in the view.
  556. *
  557. * @param \Cake\ORM\Table|string|\Cake\ORM\Query|null $object Table to paginate
  558. * (e.g: Table instance, 'TableName' or a Query object)
  559. * @return \Cake\ORM\ResultSet Query results
  560. * @link http://book.cakephp.org/3.0/en/controllers.html#Controller::paginate
  561. * @throws \RuntimeException When no compatible table object can be found.
  562. */
  563. public function paginate($object = null)
  564. {
  565. if (is_object($object)) {
  566. $table = $object;
  567. }
  568. if (is_string($object) || $object === null) {
  569. $try = [$object, $this->modelClass];
  570. foreach ($try as $tableName) {
  571. if (empty($tableName)) {
  572. continue;
  573. }
  574. $table = TableRegistry::get($tableName);
  575. break;
  576. }
  577. }
  578. $this->loadComponent('Paginator');
  579. if (empty($table)) {
  580. throw new \RuntimeException('Unable to locate an object compatible with paginate.');
  581. }
  582. return $this->Paginator->paginate($table, $this->paginate);
  583. }
  584. /**
  585. * Method to check that an action is accessible from a URL.
  586. *
  587. * Override this method to change which controller methods can be reached.
  588. * The default implementation disallows access to all methods defined on Cake\Controller\Controller,
  589. * and allows all public methods on all subclasses of this class.
  590. *
  591. * @param string $action The action to check.
  592. * @return bool Whether or not the method is accessible from a URL.
  593. */
  594. public function isAction($action)
  595. {
  596. try {
  597. $method = new ReflectionMethod($this, $action);
  598. } catch (\ReflectionException $e) {
  599. return false;
  600. }
  601. if (!$method->isPublic()) {
  602. return false;
  603. }
  604. if ($method->getDeclaringClass()->name === 'Cake\Controller\Controller') {
  605. return false;
  606. }
  607. return true;
  608. }
  609. /**
  610. * Called before the controller action. You can use this method to configure and customize components
  611. * or perform logic that needs to happen before each controller action.
  612. *
  613. * @param Event $event An Event instance
  614. * @return void
  615. * @link http://book.cakephp.org/3.0/en/controllers.html#request-life-cycle-callbacks
  616. */
  617. public function beforeFilter(Event $event)
  618. {
  619. }
  620. /**
  621. * Called after the controller action is run, but before the view is rendered. You can use this method
  622. * to perform logic or set view variables that are required on every request.
  623. *
  624. * @param Event $event An Event instance
  625. * @return void
  626. * @link http://book.cakephp.org/3.0/en/controllers.html#request-life-cycle-callbacks
  627. */
  628. public function beforeRender(Event $event)
  629. {
  630. }
  631. /**
  632. * The beforeRedirect method is invoked when the controller's redirect method is called but before any
  633. * further action.
  634. *
  635. * If the event is stopped the controller will not continue on to redirect the request.
  636. * The $url and $status variables have same meaning as for the controller's method.
  637. * You can set the event result to response instance or modify the redirect location
  638. * using controller's response instance.
  639. *
  640. * @param Event $event An Event instance
  641. * @param string|array $url A string or array-based URL pointing to another location within the app,
  642. * or an absolute URL
  643. * @param \Cake\Network\Response $response The response object.
  644. * @return void
  645. * @link http://book.cakephp.org/3.0/en/controllers.html#request-life-cycle-callbacks
  646. */
  647. public function beforeRedirect(Event $event, $url, Response $response)
  648. {
  649. }
  650. /**
  651. * Called after the controller action is run and rendered.
  652. *
  653. * @param Event $event An Event instance
  654. * @return void
  655. * @link http://book.cakephp.org/3.0/en/controllers.html#request-life-cycle-callbacks
  656. */
  657. public function afterFilter(Event $event)
  658. {
  659. }
  660. }