Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • ActiveRecord
  • Cache
  • Configs
  • Core
  • DateTime
  • Debug
  • DeleteOperation
  • Errors
  • Event
  • EventHook
  • Events
  • FileCache
  • FormattedString
  • Helpers
  • I18n
  • Image
  • Inflections
  • Inflector
  • Models
  • Module
  • Modules
  • Object
  • Operation
  • PingOperation
  • Prototype
  • Route
  • Routes
  • SaveOperation
  • Session
  • TimeZone
  • TimeZoneLocation
  • Uploaded
  • Vars
  • VarsIterator

Interfaces

  • StorageInterface
  • ToArray
  • ToArrayRecursive

Traits

  • PrototypeTrait
  • ToArrayRecursiveTrait

Exceptions

  • AlreadyAuthenticated
  • AuthenticationRequired
  • Exception
  • ModuleConstructorMissing
  • ModuleIsDisabled
  • ModuleNotDefined
  • OffsetError
  • OffsetNotDefined
  • OffsetNotReadable
  • OffsetNotWritable
  • PermissionRequired
  • PropertyError
  • PropertyIsReserved
  • PropertyNotDefined
  • PropertyNotReadable
  • PropertyNotWritable
  • RouteNotDefined
  • SecurityException

Constants

  • TOKEN_ALPHA
  • TOKEN_ALPHA_UPCASE
  • TOKEN_NUMERIC
  • TOKEN_SYMBOL
  • TOKEN_SYMBOL_WIDE

Functions

  • array_flatten
  • array_insert
  • array_merge_recursive
  • camelize
  • capitalize
  • downcase
  • dump
  • escape
  • escape_all
  • exact_array_merge_recursive
  • excerpt
  • format
  • generate_token
  • generate_token_wide
  • generate_v4_uuid
  • get_autoconfig
  • humanize
  • hyphenate
  • log
  • log_error
  • log_info
  • log_success
  • log_time
  • normalize
  • normalize_namespace_part
  • normalize_url_path
  • pbkdf2
  • pluralize
  • remove_accents
  • shorten
  • singularize
  • sort_by_weight
  • stable_sort
  • strip_root
  • titleize
  • unaccent_compare
  • unaccent_compare_ci
  • underscore
  • upcase
  1 <?php
  2 
  3 /*
  4  * This file is part of the ICanBoogie package.
  5  *
  6  * (c) Olivier Laviale <olivier.laviale@gmail.com>
  7  *
  8  * For the full copyright and license information, please view the LICENSE
  9  * file that was distributed with this source code.
 10  */
 11 
 12 namespace ICanBoogie;
 13 
 14 /**
 15  * @property-read int $code The code of the exception that can be used as HTTP status code.
 16  * @property-read string $message The message of the exception.
 17  */
 18 class Exception extends \Exception
 19 {
 20     protected $code;
 21     public $title = 'Exception';
 22 
 23     public function __construct($message, array $params=[], $code=500, $previous=null)
 24     {
 25         static $codes = [
 26 
 27             400 => 'Bad Request',
 28             401 => 'Unauthorized',
 29             402 => 'Payment Required',
 30             403 => 'Forbidden',
 31             404 => 'Not Found',
 32             405 => 'Method Not Allowed',
 33             406 => 'Not Acceptable',
 34             407 => 'Proxy Authentication Required',
 35             408 => 'Request Timeout',
 36             409 => 'Conflict',
 37             410 => 'Gone',
 38             411 => 'Length Required',
 39             412 => 'Precondition Failed',
 40             413 => 'Request Entity Too Large',
 41             414 => 'Request-URI Too Long',
 42             415 => 'Unsupported Media Type',
 43             416 => 'Requested Range Not Satisfiable',
 44             417 => 'Expectation Failed',
 45 
 46             500 => 'Internal Server Error',
 47             501 => 'Not Implemented',
 48             502 => 'Bad Gateway',
 49             503 => 'Service Unavailable',
 50             504 => 'Gateway Timeout',
 51             505 => 'HTTP Version Not Supported'
 52 
 53         ];
 54 
 55         $this->code = $code;
 56 
 57         if (is_array($code))
 58         {
 59             $this->code = key($code);
 60             $this->title = array_shift($code);
 61         }
 62         else if (isset($codes[$code]))
 63         {
 64             $this->title = $codes[$code];
 65         }
 66 
 67         #
 68         # the error message is localized and formatted
 69         #
 70 
 71         $message = \ICanBoogie\format($message, $params);
 72 
 73         parent::__construct($message, $code, $previous);
 74     }
 75 
 76     /**
 77      * Returns the read-only properties {@link $code} and {@link $message}.
 78      *
 79      * @param string $property The property to get.
 80      *
 81      * @throws PropertyNotReadable When the property is unaccessible.
 82      *
 83      * @return mixed
 84      */
 85     public function __get($property)
 86     {
 87         switch ($property)
 88         {
 89             case 'message': return $this->getMessage();
 90             case 'code': return $this->code;
 91         }
 92 
 93         throw new PropertyNotReadable([ $property, $this ]);
 94     }
 95 
 96     public function __toString()
 97     {
 98         if ($this->code && !headers_sent())
 99         {
100             header('HTTP/1.0 ' . $this->code . ' ' . $this->title);
101         }
102 
103         $message = Debug::format_alert($this);
104 
105         Debug::report($message);
106 
107         return $message;
108     }
109 
110     public function getTitle()
111     {
112         return $this->code . ' ' . $this->title;
113     }
114 
115     /**
116      * Alters the HTTP header according to the exception code and title.
117      */
118     public function alter_header()
119     {
120         header("HTTP/1.0 $this->code $this->title");
121     }
122 }
123 
124 /**
125  * Exception thrown when a security error occurs.
126  *
127  * This is a base class for security exceptions, one should rather use the
128  * {@link AuthenticationRequired} and {@link PermissionRequired} exceptions.
129  */
130 class SecurityException extends \Exception
131 {
132 
133 }
134 
135 /**
136  * Exception thrown when user authentication is required.
137  */
138 class AuthenticationRequired extends SecurityException
139 {
140     public function __construct($message="The requested URL requires authentication.", $code=401, \Exception $previous=null)
141     {
142         parent::__construct($message, $code, $previous);
143     }
144 }
145 
146 /**
147  * Exception thrown when the user is already authenticated.
148  *
149  * Third parties may use this exception to redirect authenticated user from a login page to their
150  * profile page.
151  */
152 class AlreadyAuthenticated extends SecurityException
153 {
154     public function __construct($message="The user is already authenticated", $code=401, \Exception $previous=null)
155     {
156         parent::__construct($message, $code, $previous);
157     }
158 }
159 
160 /**
161  * Exception thrown when a user doesn't have the required permission.
162  */
163 class PermissionRequired extends SecurityException
164 {
165     public function __construct($message="You don't have the required permission.", $code=401, \Exception $previous=null)
166     {
167         parent::__construct($message, $code, $previous);
168     }
169 }
Autodoc API documentation generated by ApiGen 2.8.0