public function __get($name) { if ($name == 'tpl') { if (!$this->_templateInitialized) { $this->initTemplate(); } return $this->_template; } if ($name == 'router') { return Router::getInstance(); } if ($name == 'session') { return Session::getInstance(); } if ($name == 'config') { return Config::getInstance(); } if ($name == 'log') { return Logger::getInstance(); } if ($name == 'language') { return Language::getInstance(); } if ($name == 'model') { return Model::getInstance(); } }
private function __construct() { //set_exception_handler(array($this, '_exceptionHandler')); Loader::registerNamespace('Framework', dirname(__FILE__) . DIRECTORY_SEPARATOR); Loader::registerAutoLoad(); $this->_config = Config::getInstance(); if ($this->_config->getConfigFolder() == null) { $this->setConfigFolder('../config'); } }
function __construct($app = 'default') { $this->logger = new Logger($app); $logging_path = Config::get('log.' . $app); if (Config::get('app.debug', false) == true) { $mode = Logger::DEBUG; } else { $mode = Logger::ERROR; } $this->logger->pushHandler(new StreamHandler($logging_path, $mode)); }
public function run() { if ($this->_config->getConfigFolder() == null) { $this->setConfigFolder('ConferenceScheduler/config'); } if ($this->_session == null) { $sessionInfo = $this->_config->app['session']; if ($sessionInfo['auto_start']) { if ($sessionInfo['type'] == 'native') { $this->_session = new NativeSession($sessionInfo['name'], $sessionInfo['lifetime'], $sessionInfo['path'], $sessionInfo['domain'], $sessionInfo['secure']); } } } }
private static function getTemplateResponse($templateId, $userRequest) { if (is_null($templateId) || trim($templateId) == "") { $templateId = self::$defaultTemplateId; } $templateInfo = FrameworkTemplate_table::getTemplateInfo($templateId); $templateClass = $templateInfo["class"]; $templateFile = $templateInfo["file"]; $className = \Config::getTemplatesNamespace() . $templateClass; $templ = new $className(); $userRequest->setTemplateId($templateId); $userResponse = $templ->getView(clone $userRequest); return $userResponse; }
public function run() { if ($this->_config->getConfigFolder() == null) { $this->setConfigFolder('ShoppingCart/Configurations'); } $this->_frontController = FrontController::getInstance(); if ($this->_router instanceof IRouter) { $this->_frontController->setRouter($this->_router); } if ($this->_router == null) { $this->_frontController->setRouter(new DefaultRouter()); } if ($this->_session == null) { $sessionInfo = $this->_config->app['session']; if ($sessionInfo['auto_start']) { if ($sessionInfo['type'] == 'native') { $this->_session = new DefaultSession($sessionInfo['name'], $sessionInfo['lifetime'], $sessionInfo['path'], $sessionInfo['domain'], $sessionInfo['secure']); } } } $this->_frontController->dispatch(); }
function sendMessage($queue, $data, $delay = 0) { $data['randomize'] = md5(rand(0, 1000000000) . rand(0, 1000000000) . rand(0, 1000000000)); $score = date("U") + $delay; Redis::zadd('cinnamon-queue-' . $queue, $score, json_encode($data)); if (Config::get('queue.auto_run', false) && defined('__APP__')) { $base_path = __APP__; if (!file_exists($base_path . "/commands/subscribe.php")) { $base_path = __APP__ . "/vendor/cinnamonlab/queue"; } $ip = $_SERVER['SERVER_ADDR']; $process = Redis::get('cinnamon-process-' . $ip); if ($process != null) { if ($process > date('U') - 600) { Redis::publish('cinnamon-process', $queue); return $this; } ob_start(); system("ps ax|grep commands/subscribe.php| grep -v grep"); $process = trim(ob_get_clean()); if (strlen($process) > 0) { Redis::set('cinnamon-process-' . $ip, date('U')); Redis::expire('cinnamon-process-' . $ip, 1200); Redis::publish('cinnamon-process', $queue); return $this; } else { Redis::del('cinnamon-process-' . $ip); } $process = null; } $cmd = "nohup " . Config::get('queue.php_path', '/usr/bin/php') . " " . $base_path . "/commands/subscribe.php {$ip} > /dev/null &"; exec($cmd); Redis::publish('cinnamon-process', $queue); } return $this; }
private function __construct() { \Framework\Loader::registerNamespace('Framework', dirname(__FILE__) . DIRECTORY_SEPARATOR); \Framework\Loader::registerAutoload(); $this->_config = \Framework\Config::getInstance(); }
/** * Get the fully qualified path for a compiled view. * * @param string $view * @return string */ public static function compiled($path) { return Config::get('blade.storage') . '/' . md5($path); }
<?php use Framework\Queue\QueueProcessor; use Framework\Config; use Framework\Queue\Driver\Driver; use Framework\Queue\Driver\RedisDriver; use Framework\Exception\FrameworkException; use Framework\Input; use Framework\Route; define('__APP__', __DIR__ . "/.."); require __APP__ . "/vendor/autoload.php"; $rs = Config::get('driver', new RedisDriver()); if (!$rs instanceof Driver) { throw FrameworkException::internalError('Queue Driver Not Set'); } QueueProcessor::getInstance()->setDriver($rs)->setAsReceiver(); for ($i = 0; $i < 10; $i++) { $message = $rs->receiveMessage('route'); if (!$message) { exit; } Input::bind($message); Route::reset(); Route::setSkipMain(); include __APP__ . "/route.php"; }
function hello() { return (new Response())->setContent(Config::get('app.greeting') . Input::get('name', 'guest'))->setContentType('text/plain')->setCode(200); }
public static function getInstance() { if (self::$myself == null) { self::$myself = new Redis(Config::get('redis.servers')); } return self::$myself; }
function __construct($template) { $this->path = Config::get('blade.template') . "/" . preg_replace("/\\./", "/", $template) . ".php"; parent::__construct(); }
use framework\Logger; use framework\Language; use framework\autoloader\Globalizer; use framework\error\ErrorManager; use framework\error\ExceptionManager; use framework\error\observers\Display; use framework\error\observers\Log; use framework\logger\observers\Write; use framework\logger\observers\Mail; use framework\mvc\Template; use framework\mvc\Router; use framework\utility\Cookie; use framework\utility\Date; // Load config Config::setPath(PATH_CONFIG); Config::getInstance(); // Setting if (defined('TIMEZONE')) { Date::setDateDefaultTimezone(TIMEZONE); } if (defined('ENVIRONNEMENT')) { static::setEnv(ENVIRONNEMENT); } // Autoloader cache if (defined('AUTOLOADER_CACHE') && !static::getDebug()) { Autoloader::setCache(AUTOLOADER_CACHE); //Globalize essentials classes if (defined('AUTOLOADER_GLOBALIZER') && AUTOLOADER_GLOBALIZER) { $globalizer = new Globalizer(static::getGlobalizeClassList(), true); $globalizer->loadGlobalizedClass(); }
private function handleError(FrameworkException $e) { if ($this->error_response == null) { if (Config::has('app.error_response')) { $this->error_response = Config::get('app.error_response'); } else { if (Config::get('app.debug', true)) { $this->error_response = new ErrorDisplayResponse(); } else { $this->error_response = new ErrorResponse(); } } } $this->error_response->set($e)->display(); return true; }
/** * */ static function emptyImage() { $output = new Imagick(); $output->setFormat("gif"); $output->newImage(Config::get('image.default.width'), Config::get('image.default.height'), new ImagickPixel(Config::get('image.default.bg_color'))); return $output->getimagesblob(); }
function __construct() { $this->sql = \Framework\Databases::getMysqlInstance(); $this->config = \Framework\Config::getInstance(); }