wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
class.ApplicationException.php
Go to the documentation of this file.
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2014 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of any of the following licenses
7  * at your choice:
8  *
9  * - GNU Lesser General Public License (LGPL)
10  * http://www.gnu.org/licenses/lgpl.html
11  * - Eclipse Public License (EPL)
12  * http://www.eclipse.org/org/documents/epl-v10.php
13  *
14  * See the license.txt file distributed with this work for
15  * additional information.
16  *
17  * $Id: class.ApplicationException.php 1462 2014-02-04 23:52:27Z iherwig $
18  */
19 require_once(BASE."wcmf/lib/presentation/class.Request.php");
20 require_once(BASE."wcmf/lib/presentation/class.Response.php");
21 
22 /**
23  * @class ApplicationException
24  *
25  * @author ingo herwig <ingo@wemove.com>
26  */
27 class ApplicationException extends Exception
28 {
29  private $_request = null;
30  private $_response = null;
31 
32  /**
33  * Constructor
34  * @param request The current request
35  * @param response The current response
36  * @param message The exception message
37  * @param code The exception code
38  * @param previous The previous exception
39  */
40  public function __construct(Request $request, Response $response, $message=null, $code=0)
41  {
42  $this->_request = $request;
43  $this->_response = $response;
44 
45  parent::__construct($message, $code);
46  }
47 
48  /**
49  * Get the current request
50  * @return The Request instance
51  */
52  public function getRequest()
53  {
54  return $this->_request;
55  }
56 
57  /**
58  * Get the current response
59  * @return The Response instance
60  */
61  public function getResponse()
62  {
63  return $this->_response;
64  }
65 
66  /**
67  * Get the string representation of the exception code.
68  * Exception codes are defined as constants of the form: const CODE_STRING = CODE_NUMBER
69  * @return The exception code string
70  */
71  public function getCodeString()
72  {
73  $class = new ReflectionClass(get_class($this));
74  $codeMap = array_flip($class->getConstants());
75  if (isset($codeMap[$this->getCode()])) {
76  return $codeMap[$this->getCode()];
77  }
78  else {
79  return '';
80  }
81  }
82 }
83 ?>
Request holds the request values that are used as input to Controller instances. It is typically inst...
Response holds the response values that are used as output from Controller instances. It is typically instantiated by the ActionMapper instance and filled during Controller execution.
__construct(Request $request, Response $response, $message=null, $code=0)