/** * Конструктор * Инициализация: * - сессий * - конфигурации приложения * - секций и блоков * - создание подключений к БД * - расширений */ protected function __construct() { try { Session::init(); /* * Extensions setup and initialize */ $this->extensions = new Std(); if (isset($this->config->extensions)) { foreach ($this->config->extensions as $extension => $options) { $extensionClassName = 'Extensions\\' . ucfirst($extension) . '\\Extension'; if (class_exists('\\App\\' . $extensionClassName)) { $extensionClassName = '\\App\\' . $extensionClassName; } else { $extensionClassName = '\\T4\\' . $extensionClassName; } $this->extensions->{$extension} = new $extensionClassName($options); $this->extensions->{$extension}->setApp($this); if (!isset($options->autoload) || true == $options->autoload) { $this->extensions->{$extension}->init(); } } } } catch (Exception $e) { echo $e->getMessage(); die; } }
/** * Запуск веб-приложения * и формирование ответа */ public function run() { try { Session::init(); $this->initExtensions(); $this->runRequest($this->request); } catch (Exception $e) { try { if ($e instanceof E404Exception) { header("HTTP/1.0 404 Not Found", true, 404); if (!empty($this->config->errors['404'])) { $this->runRoute($this->config->errors['404']); } else { echo $e->getMessage(); } } elseif ($e instanceof E403Exception) { header('HTTP/1.0 403 Forbidden', true, 403); if (!empty($this->config->errors['403'])) { $this->runRoute($this->config->errors['403']); } else { echo $e->getMessage(); } } else { echo $e->getMessage(); die; } } catch (Exception $e2) { echo $e2->getMessage(); die; } } }
public static function getLocation() { if (null == Session::get('location')) { $app = \T4\Mvc\Application::getInstance(); Session::set('location', $app->extensions->sxgeo->getLocation($app->request->ip)); } return Session::get('location'); }
public function checkKeyString($string) { return Session::get(self::KEYSTRING_KEY) == $string; }
public function addToCart(Product $product) { Session::set('product', $product->getPk()); }
protected function init() { Session::init(); $this->initExtensions(); }
public function getTotalFromCart() { return Session::get(self::$sessionProductsListVar)->count(); }