Пример #1
0
 private function helpersLoading($namespace, $folder)
 {
     Memory::create(HELPER);
     if (is_dir($folder . DS . ucfirst(HELPER))) {
         $this->loadFromDir(HELPER, $folder . DS . ucfirst(HELPER), '\\' . $namespace . '\\' . ucfirst(HELPER) . '\\');
     }
 }
Пример #2
0
 /**
  * A basic usage of error_log
  * See http://php.net/manual/en/function.error-log.php to configure it;
  **/
 public function __construct($level = DEBUG, int $message_type = 0, string $destination = null, string $extra_headers = null)
 {
     $this->setBaseLevel($level);
     Memory::events()->on(LOG, function (string $level, string $message) use($message_type, $destination, $extra_headers) {
         if ($this->isLoggable($level)) {
             error_log($message, $message_type, $destination, $extra_headers);
         }
     });
 }
Пример #3
0
 public function attachEvents()
 {
     foreach (Memory::get(ACTION) as $namespace => $action) {
         $this->attachActionEvents($action, $namespace);
     }
     foreach (Memory::get(VIEW) as $namespace => $view) {
         $this->attachViewEvents($view, $namespace);
     }
 }
Пример #4
0
 public function redirect($location, array $args = [])
 {
     if (false === stripos($location, '/')) {
         $url = new UrlHelper();
         $url->setArguments(array_merge(['url' => $location], $args));
         $location = $url->render();
     }
     Memory::get(HTTP)->set(HEADER, ['Location' => $location]);
     Memory::get(HTTP)->set(CODE, 302);
     Memory::events()->emit(END, ['content' => '']);
     Memory::events()->emit(STOP);
 }
Пример #5
0
 public function getCacheDir()
 {
     return Memory::get(SCOPE)->get(CACHE, false) ?: Memory::get(SCOPE)->get(BASE) . DS . CACHE . DS;
 }
Пример #6
0
 public function log(string $level, string $message, array $context = [])
 {
     $time = date('d/m/Y ~ G\\:i ');
     Memory::events()->emit(LOG, ['level' => $level, 'message' => $time . '[' . $level . '] ' . $message, 'context' => $context]);
 }
Пример #7
0
 public function __construct()
 {
     Memory::events()->on('stop::rendering', function () {
         $this->outlets = [];
     });
 }