[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE 8 */ 9 10 namespace Joomla\CMS\Error\JsonApi; 11 12 use Exception; 13 use Joomla\CMS\MVC\Controller\Exception\Save; 14 use Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface; 15 use Tobscure\JsonApi\Exception\Handler\ResponseBag; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('_JEXEC') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Handler for invalid checkin/checkout exceptions 23 * 24 * @since 4.0.0 25 */ 26 class SaveExceptionHandler implements ExceptionHandlerInterface 27 { 28 /** 29 * If the exception handler is able to format a response for the provided exception, 30 * then the implementation should return true. 31 * 32 * @param \Exception $e The exception to be handled 33 * 34 * @return boolean 35 * 36 * @since 4.0.0 37 */ 38 public function manages(Exception $e) 39 { 40 return $e instanceof Save; 41 } 42 43 /** 44 * Handle the provided exception. 45 * 46 * @param Exception $e The exception being handled 47 * 48 * @return \Tobscure\JsonApi\Exception\Handler\ResponseBag 49 * 50 * @since 4.0.0 51 */ 52 public function handle(Exception $e) 53 { 54 $status = 400; 55 56 if ($e->getCode()) { 57 $status = $e->getCode(); 58 } 59 60 $error = [ 61 'title' => $e->getMessage(), 62 'code' => $status, 63 ]; 64 65 return new ResponseBag($status, [$error]); 66 } 67 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |