Beispiel #1
0
 /**
  * Main Exception handler
  * @param string  $message   message to display
  * @param array   $variables variables to replace in message
  * @param integer $code 	 HTTP response code to set
  */
 public function __construct($message, $variables = NULL, $code = 500)
 {
     if (is_array($variables)) {
         foreach ($variables as $key => $value) {
             $message = str_replace($key, $value, $message);
         }
     }
     $errorHandler = Core::instance()->errorHandler();
     if ($errorHandler) {
         $errorHandler->sendHttpCode($code);
     }
     return parent::__construct($message, $code);
 }
Beispiel #2
0
 /**
  * Constructor of the file handler
  * @uses Stativo\Core\Core
  */
 public function __construct()
 {
     // Load all findable directories
     $vendor_paths = Core::config('app')->get('find-vendor');
     // Add app path to 'vendors' list
     self::$_vendors['Stativo\\App'] = APPPATH;
     // Create paths and namespaces
     foreach ($vendor_paths as $namespace => $path) {
         $vendor_path = DOCROOT . 'vendor' . DIRECTORY_SEPARATOR . str_replace(['/'], [DIRECTORY_SEPARATOR], trim($path, '/')) . DIRECTORY_SEPARATOR;
         // Check if vendor path exists.
         if (!file_exists($vendor_path)) {
             throw new MainException("Could not find vendor path: :path", [':path' => $vendor_path]);
         }
         if (file_exists($vendor_path . 'routes.php')) {
             require $vendor_path . 'routes.php';
         }
         // Set vendor
         self::$_vendors[$namespace] = $vendor_path;
     }
 }
Beispiel #3
0
 /**
  * Returns a singleton instance of Encrypt. An encryption key must be
  * provided in your "encrypt" configuration file.
  *
  *     ```
  *      $encrypt = Encrypt::instance();
  *      dd($encrypt->encode('test'));
  *     ```
  *
  * @uses Stativo\Helpers\Encrypt
  * @uses Stativo\Helpers\MainException
  * @uses Stativo\Core\Core
  * @param   string  $name   configuration group name
  * @return  Encrypt
  */
 public static function instance()
 {
     if (!isset(Encrypt::$instance)) {
         // Load the configuration data
         $config = Core::config('app')->toArray();
         $config = $config['encrypt'];
         if (!isset($config['key'])) {
             // No default encryption key is provided!
             throw new MainException('No key is defined in the encryption configuration');
         }
         if (!isset($config['mode'])) {
             // Add the default mode
             $config['mode'] = MCRYPT_MODE_NOFB;
         }
         if (!isset($config['cipher'])) {
             // Add the default cipher
             $config['cipher'] = MCRYPT_RIJNDAEL_256;
         }
         // Create a new instance
         Encrypt::$instance = new Encrypt($config['key'], $config['mode'], $config['cipher']);
     }
     return Encrypt::$instance;
 }
Beispiel #4
0
 /**
  * Language class constructor
  *
  * @uses Stativo\Core\Core
  * @param string $locale locale like en_US
  */
 public function __construct($locale = NULL)
 {
     self::$_config = Core::config('app')->get('language');
     if ($locale !== NULL) {
         self::$_config['default'] = $locale;
     }
     $language_code = strtolower(self::$_config['default']);
     self::$_config['path'] = APPPATH . 'Language' . DIRECTORY_SEPARATOR . $language_code . DIRECTORY_SEPARATOR;
     self::$_language_code = $language_code;
     $filesList = File::lists('Language' . DIRECTORY_SEPARATOR . self::$_language_code);
     self::$_language_array = array();
     foreach ($filesList as $namespace => $files) {
         foreach ($files as $file) {
             self::$_language_array[] = (require self::$_config['path'] . $file . '.php');
         }
     }
     foreach (self::$_language_array as $inner) {
         foreach ($inner as $key => $value) {
             self::$_language[$key] = $value;
         }
     }
     return $this;
 }
Beispiel #5
0
 /**
  * Holds the current server URI. Exists of the domain/ip stripped of protocol and slashes
  * @return string base uri
  */
 public static function uri()
 {
     return ltrim(strtolower(rtrim(self::instance()->server('REQUEST_URI'), Core::config('app')->get('base_url'))), '/');
 }
Beispiel #6
0
 /**
  * Class constructor
  */
 public function __construct()
 {
     $this->_core = Core::instance();
     return $this;
 }