Hawk - PHP documentation
  • Namespace
  • Class
  • Tree

Namespaces

  • Hawk
    • View
      • Plugins

Classes

  • Hawk\App
  • Hawk\ButtonInput
  • Hawk\Cache
  • Hawk\CheckboxInput
  • Hawk\ColorInput
  • Hawk\Conf
  • Hawk\Controller
  • Hawk\Crypto
  • Hawk\DatabaseSessionHandler
  • Hawk\DatetimeInput
  • Hawk\DB
  • Hawk\DBExample
  • Hawk\DeleteInput
  • Hawk\Dialogbox
  • Hawk\EmailInput
  • Hawk\ErrorHandler
  • Hawk\Event
  • Hawk\FileInput
  • Hawk\FileSystem
  • Hawk\FloatInput
  • Hawk\Form
  • Hawk\FormFieldset
  • Hawk\FormInput
  • Hawk\GenericModel
  • Hawk\GifImage
  • Hawk\HawkApi
  • Hawk\HawkUpdater
  • Hawk\HiddenInput
  • Hawk\HtmlInput
  • Hawk\HTTPRequest
  • Hawk\Icon
  • Hawk\Image
  • Hawk\IntegerInput
  • Hawk\ItemList
  • Hawk\ItemListField
  • Hawk\JpegImage
  • Hawk\Lang
  • Hawk\Language
  • Hawk\LeftSidebarTab
  • Hawk\Less
  • Hawk\Logger
  • Hawk\Mail
  • Hawk\MenuItem
  • Hawk\Model
  • Hawk\NoSidebarTab
  • Hawk\NumberInput
  • Hawk\ObjectInput
  • Hawk\Option
  • Hawk\Panel
  • Hawk\PasswordInput
  • Hawk\Permission
  • Hawk\Plugin
  • Hawk\PluginInstaller
  • Hawk\PngImage
  • Hawk\ProfileQuestion
  • Hawk\ProfileQuestionValue
  • Hawk\RadioInput
  • Hawk\Request
  • Hawk\Response
  • Hawk\RightSidebarTab
  • Hawk\Role
  • Hawk\RolePermission
  • Hawk\Route
  • Hawk\Router
  • Hawk\SelectInput
  • Hawk\Session
  • Hawk\Singleton
  • Hawk\SubmitInput
  • Hawk\Tabs
  • Hawk\TextareaInput
  • Hawk\TextInput
  • Hawk\Theme
  • Hawk\TimeInput
  • Hawk\Upload
  • Hawk\User
  • Hawk\View
  • Hawk\View\Plugins\Accordion
  • Hawk\View\Plugins\Button
  • Hawk\View\Plugins\Form
  • Hawk\View\Plugins\Icon
  • Hawk\View\Plugins\Import
  • Hawk\View\Plugins\Panel
  • Hawk\View\Plugins\Tabs
  • Hawk\View\Plugins\Text
  • Hawk\View\Plugins\Uri
  • Hawk\View\Plugins\Widget
  • Hawk\ViewPlugin
  • Hawk\Widget
  • Hawk\WysiwygInput

Traits

  • Hawk\Utils

Exceptions

  • Hawk\AppStopException
  • Hawk\DBExampleException
  • Hawk\DBException
  • Hawk\FileSystemException
  • Hawk\HawkApiException
  • Hawk\ImageException
  • Hawk\MailException
  • Hawk\UploadException
  • Hawk\ViewException
 1 <?php
 2 
 3 /**
 4  * App.php
 5  *
 6  * @author  Elvyrra SAS
 7  * @license http://rem.mit-license.org/ MIT
 8  */
 9 
10 namespace Hawk;
11 
12 /**
13  * This class is used to generate the application singletons. It is loaded at script start, and initialize the following
14  * singletons : conf, errorHandler, logger, fs (FileSystem), session, router, request, response, cache and db
15  *
16  * @package Core
17  */
18 final class App extends Singleton{
19     /**
20      * The application instance
21      */
22     protected static $instance;
23 
24 
25     /**
26      * Initialize the application
27      */
28     public function init(){
29         // Load the application configuration
30         $this->singleton('conf', Conf::getInstance());
31 
32         // Load the application error Handler
33         $this->singleton('errorHandler', ErrorHandler::getInstance());
34 
35         // Load the application logger
36         $this->singleton('logger', Logger::getInstance());
37 
38         // Load the filesystem library
39         $this->singleton('fs', FileSystem::getInstance());
40 
41         // Load the application session
42         $this->singleton('session', Session::getInstance());
43 
44         // Load the application router
45         $this->singleton('router', Router::getInstance());
46 
47         // Load the application HTTP request
48         $this->singleton('request', Request::getInstance());
49 
50         // Load the application HTTP response
51         $this->singleton('response', Response::getInstance());
52 
53         // Load the application cache
54         $this->singleton('cache', Cache::getInstance());
55     }
56 
57 
58     /**
59      * Create an application singleton
60      *
61      * @param string $name     The singleton name, that will running by App::{$name}().
62      *                         For example, if $name = 'db', the singleton will be accessible by App::db();
63      * @param object $instance The singleton instance
64      */
65     public function singleton($name, $instance){
66         $this->$name = $instance;
67     }
68 
69     /**
70      * Call a singleton
71      *
72      * @param string $method    The method name, corresponding to the singleton name
73      * @param array  $arguments The singleton arguments (not used, but mandatory when overriding __callStatic method)
74      */
75     public static function __callStatic($method, $arguments){
76         if(isset(self::$instance->$method)) {
77             return self::$instance->$method;
78         }
79         else{
80             throw new \Exception('The application singleton "' . $method . '" has not been initiated');
81         }
82     }
83 }
84 
85 /**
86  * Throw this exception to force the script to finish properly
87  *
88  * @package Exceptions
89  */
90 class AppStopException extends \Exception{
91 
92 }
93 
Hawk - PHP documentation API documentation generated by ApiGen