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) . '\\'); } }
/** * 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); } }); }
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); } }
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); }
public function getCacheDir() { return Memory::get(SCOPE)->get(CACHE, false) ?: Memory::get(SCOPE)->get(BASE) . DS . CACHE . DS; }
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]); }
public function __construct() { Memory::events()->on('stop::rendering', function () { $this->outlets = []; }); }