Cake\Network\Response::stop PHP Method

stop() public method

Stop execution of the current script. Wraps exit() making testing easier.
public stop ( integer | string $status ) : void
$status integer | string See http://php.net/exit for values
return void
    public function stop($status = 0)
    {
        exit($status);
    }

Usage Example

 /**
  * Handles (fakes) redirects for Ajax requests using requestAction()
  *
  * @param Event $event The Controller.beforeRedirect event.
  * @param string|array $url A string or array containing the redirect location
  * @param \Cake\Network\Response $response The response object.
  * @return void
  */
 public function beforeRedirect(Event $event, $url, Response $response)
 {
     $request = $this->request;
     if (!$request->is('ajax')) {
         return;
     }
     if (empty($url)) {
         return;
     }
     if (is_array($url)) {
         $url = Router::url($url + ['_base' => false]);
     }
     $controller = $event->subject();
     $response->body($controller->requestAction($url, ['return', 'bare' => false, 'environment' => ['REQUEST_METHOD' => 'GET']]));
     $response->send();
     $response->stop();
 }
All Usage Examples Of Cake\Network\Response::stop