private function __construct() { $config = array(); $config = Config::getConfigItems('config_items'); $this->config = $config['session_config']; $this->initialize(); }
/** * Convert Html special characters. * * Encoding will be used based on configuration given in Config file. * * @false string $value * * @param $value * * @throws InvalidArgumentException * * @return string */ public static function specialCharacters($value) { if (is_null($value)) { throw new InvalidArgumentException('Cannot pass null argument to ' . __METHOD__); } return htmlspecialchars($value, ENT_QUOTES, Config::get('global.config', 'encoding'), false); }
/** * @param \Cygnite\Foundation\Application $app * @internal param $route */ public function __construct(ApplicationInterface $app) { $this->app = $app; $this->router = $app['router']; $this->default['controller'] = lcfirst(Config::get('global.config', 'default.controller')); $this->default['action'] = lcfirst(Config::get('global.config', 'default.method')); }
public function setUp() { $configuration = ['global.config' => ['cache' => ['memcached' => ['autoconnnect' => true, 'servers' => [['host' => '127.0.0.1', 'port' => 11211, 'weight' => 50]]]]]]; Config::$config = $configuration; $this->memcached = Cache::make('memcached', function ($memcached) { return $memcached; }); }
/** * Constructor of File Cache * We will initialize file cache */ public function __construct() { $config = array('name' => Config::get('global.config', 'cache_name'), 'path' => Config::get('global.config', 'cache_directory'), 'extension' => Config::get('global.config', 'cache_extension')); if ($config['path'] == "") { throw new InvalidCacheDirectoryException('You must define cache directory to use cache.'); } $this->initialize($config); }
public function __construct(Encrypt $crypt) { $this->crypt = $crypt; $config = array(); $config = Config::getConfigItems('config_items'); $this->config = $config['config.session']; $this->initialize(); }
public function setUp() { $configuration = ['global.config' => ['cache' => ['redis' => ['connection' => 'default']]]]; Config::$config = $configuration; $this->redis = Cache::make('redis', function ($redis) { return $redis; }); }
/** * Set Social OAuth Configuration. * * @return void */ protected function configureSocialAuth() { $this->config = Config::get('global.config', 'social.config'); if (isset($this->config['active']) && !empty($this->config['active'])) { return true; } return false; }
/** * Constructor of File Cache * We will initialize file cache */ public function __construct() { $config = Config::get('global.config', 'cache'); $data = ['name' => $config['file']['name'], 'path' => $config['file']['directory'], 'extension' => $config['file']['extension']]; if ($data['path'] == "") { throw new InvalidCacheDirectoryException('You must define cache directory to use cache.'); } $this->setup($data); }
/** * Constructor of Mailer * * Configure Mailer to send email * * @param null $swift */ public function __construct($swift = null) { if (!is_null($swift)) { $this->swift = $swift; } $this->emailConfig = Config::get('global.config', 'email.configurations'); //set transport type protocol $this->setTransportType($this->emailConfig['protocol']); }
/** * @return RedisConnector|null */ private static function getRedisDriver() { $config = Config::get('global.config', 'cache'); $redis = null; if (isset($config['redis'])) { $redis = new RedisConnector(new RedisClient(), $config['redis']); } return $redis; }
/** * Session Constructor. */ public function __construct() { /* | We will set session configuration into config property | Based on user defined configuration we will load the session | driver */ $this->config = Config::get('config.session'); $this->setName($this->config['session_name']); }
public function setUp() { // Fix for header set already $prev = error_reporting(0); session_start(); error_reporting($prev); $configuration = ['config.session' => ['session_name' => 'cf_secure_session', 'use_session_cookie' => false, 'httponly' => true, 'secure' => false]]; Config::$config = $configuration; $this->session = new Session('Cygnite', null, new Cygnite\Common\SessionManager\Session()); }
/** * Constructor function * @false string - encryption key * */ public function __construct() { $encryptKey = Config::get('global.config', 'cf_encryption_key'); if (is_null($encryptKey)) { $config = (include_once CYGNITE_BASE . DS . APPPATH . DS . 'configs' . DS . 'application' . EXT); $this->setSaltKey($config['cf_encryption_key']); } else { $this->setSaltKey($encryptKey); } }
public function __construct() { $this->emailConfig = Config::get('global.config', 'emailConfiguration'); try { Application::import('vendor' . DS . $this->emailConfig['swift_mailer_path']); } catch (Exception $ex) { throw new Exception($ex->getMessage()); } //set transport type protocol $this->setTransportType($this->emailConfig['protocol']); }
private function setUpAssetConfig() { $app = Application::instance(); $app['router'] = new \Cygnite\Base\Router\Router(); $_SERVER['REQUEST_URI'] = '/hello/user/'; $_SERVER['HTTP_HOST'] = 'localhost'; $configuration = ['global.config' => ['encoding' => 'utf-8']]; Config::$config = $configuration; Url::setBase('/cygnite/'); //$app['router']->getBaseUrl() }
public function __construct() { Config::get('global.config', 'cache_name'); $cache_config = array('name' => Config::get('global.config', 'cache_name'), 'path' => Config::get('global.config', 'cache_directory'), 'extension' => Config::get('global.config', 'cache_extension')); $this->initialize($cache_config); if (Config::get('global.config', 'cache_directory') == "none") { throw new \Exception('You must define cache directory to use cache.'); } else { $this->_cachePath = APPPATH . Config::get('global.config', 'cache_directory') . '/'; } }
private function setUpAssetConfig() { $loader = m::mock("Cygnite\\Foundation\\Autoloader"); $app = Application::getInstance($loader); $app['router'] = m::mock("Cygnite\\Base\\Router\\Router"); $_SERVER['REQUEST_URI'] = '/hello/user/'; $_SERVER['HTTP_HOST'] = 'localhost'; $configuration = ['global.config' => ['encoding' => 'utf-8']]; Config::$config = $configuration; Url::setBase('/cygnite/'); //$app['router']->getBaseUrl() }
/** * @return bool */ public function terminate() { /**------------------------------------------------------------------ * Throw Exception is default controller * has not been set in configuration * ------------------------------------------------------------------ */ if (is_null(Config::get('global.config', "default_controller"))) { trigger_error("Default controller not found ! Please set the default\n controller in configs/application" . EXT); } Application::import(APPPATH . '.routes'); }
/** * Constructor function * @false string - encryption key * */ public function __construct() { $encryptKey = Config::get('global.config', 'cf_encryption_key'); if (!is_null($encryptKey)) { $this->set($encryptKey); if (!function_exists('mcrypt_create_iv')) { throw new \BadFunctionCallException("Mcrypt extension library not loaded"); } $this->iv = mcrypt_create_iv(32); } else { throw new \BadFunctionCallException("Please check for encription key inside config file and autoload helper encrypt key is set or not."); } }
private function setUpAssetConfig() { $app = Application::instance(); $app['url'] = new \Cygnite\Common\UrlManager\Url(); $app['request'] = \Cygnite\Http\Requests\Request::createFromGlobals(); $app['router'] = new \Cygnite\Base\Router\Router($app['request']); $app['url']->setApplication($app); $app['request']->server->add('REQUEST_URI', '/hello/user'); $app['request']->server->add('HTTP_HOST', 'localhost'); $configuration = ['global.config' => ['encoding' => 'utf-8']]; Config::$config = $configuration; Url::setBase('cygnite/'); //$app['router']->getBaseUrl() }
/** * Validate user request and send response to browser * * @throws \Exception * @return mixed */ public function run() { // If no argument passed or single slash call default controller if ($this->router->getCurrentUri() == '/' || $this->router->getCurrentUri() == '/' . self::$indexPage) { if ($this->default['controller'] != '') { list($controller, $action) = $this->getControllerAndAction($this->default['controller'], $this->default['action']); $response = $this->handleControllerDependencies($controller, $action); } } else { $routeConfig = Config::get('config.router'); $newUrl = str_replace('/index.php', '', rtrim($this->router->getCurrentUri())); $exp = array_filter(explode('/', $newUrl)); $matchedUrl = $this->matches($routeConfig); //Check with router configuration if matched then call defined controller if (!is_null($matchedUrl)) { $requestUri = preg_split('/[\\.\\ ]/', $matchedUrl['controllerPath']); // We are matching with static routing if match then dispatch it list($controller, $action) = $this->getControllerAndAction($requestUri[0], $requestUri[1]); if (!class_exists($controller)) { throw new Exception('Unhandled Exception (404 Page)'); } $params = (array) $matchedUrl['params']; $response = $this->handleControllerDependencies($controller, $action, $params); } else { // Process user request provided in url $controller = $method = $param = $instance = null; $controller = $exp[1]; if (isset($exp[2])) { $method = $exp[2]; } $params = array_slice($exp, 2); $controllerDir = ''; if (is_dir(CYGNITE_BASE . str_replace('\\', DS, strtolower("\\" . APPPATH . $this->app->namespace . $exp[1])))) { $controllerDir = ucfirst($exp[1]); $controller = $exp[2]; $method = $exp[3]; $params = array_slice($exp, 3); } $action = isset($method) ? $method : 'index'; list($controller, $action) = $this->getControllerAndAction($controller, $action, $controllerDir); if (!class_exists($controller)) { throw new Exception('Unhandled Exception (404 Page)'); } $response = $this->handleControllerDependencies($controller, $action, $params); } } return $response; }
public function setSessionConfig() { /* | Get user configuration */ $config = Config::get('config.session'); $sessionManager = $this->getWrapper(); $sessionManager->setHash(); // set session hash // We will use session cookie if configured if ($config['use_session_cookie']) { $sessionManager->useOnlyCookie(); // use cookie } // Make sure the session cookie is not accessible via javascript. $sessionManager->setCookieParams($config['secure'], $config['httponly']); }
private function configure() { $configuration = ['global.config' => ["encryption.key" => 'cygnite-shaXatBNHQ434']]; Config::$config = $configuration; }
/** * Set Stripe Configuration. * * @return void */ protected function configureStripe() { $this->config = Config::get('global.config', 'stripe.config'); }
/** * Initialize and do all configuration then start booting */ public function initialize() { /** * Set Environment for Application * Example: * <code> * define('DEVELOPMENT_ENVIRONMENT', 'development'); * define('DEVELOPMENT_ENVIRONMENT', 'production'); * </code> */ define('MODE', Config::get('global.config', 'environment')); global $event; if (MODE == 'development') { ini_set('display_errors', 1); error_reporting(E_ALL); } else { ini_set('display_error', 0); error_reporting(0); } $event->trigger("exception"); /** *-------------------------------------------------- * Turn on application if profiling is on * in configuration *-------------------------------------------------- */ if (Config::get('global.config', 'enable_profiling') == true) { Profiler::start(); } /** -------------------------------------------------- * Set Cygnite user defined encryption key * --------------------------------------------------- */ if (!is_null(Config::get('global.config', 'cf_encryption_key')) || in_array('encrypt', Config::get('config.autoload', 'helpers')) == true) { define('CF_ENCRYPT_KEY', Config::get('global.config', 'cf_encryption_key')); } /**---------------------------------------------------------------- * Get Session config and set it here * ---------------------------------------------------------------- */ define('SECURE_SESSION', Config::get('config.session', 'cf_session')); /**---------------------------------------------------------------- * Auto load Session library based on user configurations * ---------------------------------------------------------------- */ if (SECURE_SESSION === true) { Session::instance(); } /**------------------------------------------------------------------ * Throw Exception is default controller * has not been set in configuration * ------------------------------------------------------------------ */ if (is_null(Config::get('global.config', "default_controller"))) { trigger_error("Default controller not found ! Please set the default\n\t\t\t\t\t\t\tcontroller in configs/application" . EXT); } }
/** * @return static */ public static function create() { $encryptKey = Config::get('global.config', 'encryption.key'); if (self::$instance === null) { self::$instance = new static($encryptKey); } return self::$instance; }
<?php use Cygnite\Common\UrlManager\Url; use Cygnite\Helpers\Config; define('APP', str_replace('src/', 'src' . DS, APPPATH)); //Set URL base path. Url::setBase(Config::get('global.config', 'base_path') == '' ? $app['router']->getBaseUrl() : Config::get('global.config', 'base_path')); /* * -------------------------------------------------- * Set application encryption key * --------------------------------------------------- */ if (!is_null(Config::get('global.config', 'encryption.key'))) { define('CF_ENCRYPT_KEY', Config::get('global.config', 'encryption.key')); } /* * ---------------------------------------------------- * Throw Exception is default controller * has not been set in configuration * ---------------------------------------------------- */ if (is_null(Config::get('global.config', 'default.controller'))) { throw new \Exception('You must set default controller in ' . APPPATH . '/Configs/application.php'); }
/** * @param $module * @return bool */ public function bootstrapModule($module) { $config = Config::get('module'); $modulePath = $config['module.path'] . DS; $moduleConfigDir = $config['module.config'] . DS; $class = '\\' . APP_NS . '\\' . $this->getModuleDir() . '\\' . ucfirst($module) . '\\BootStrap'; $file = $modulePath . ucfirst($module) . DS . $moduleConfigDir . strtolower($module) . EXT; if (!file_exists($file)) { return false; } Config::setConfigurationItems(strtolower($module) . '.config', include $file); return (new $class())->register($this->getApplication(), $file); }
public function __construct($name = null, $cacheLimiter = null, $wrapperInstance = null) { $this->name = $name; /* | Override native session handler */ $this->sessionSaveHandler(); /* | Get user configuration */ $this->config = Config::get('config.session'); /* | Set Database and Table for storing | session into database */ $this->database($this->config['database_name']); $this->table($this->config['table']); $this->setWrapperInstance($wrapperInstance); /* |Check if session started if not we will start new session |if session started already we will try */ if (!session_id()) { $this->start(); } $this->storage =& $_SESSION; /* | Check csrf token already exists into session | else regenerate the token */ $this->checkToken(); // This line prevents unexpected effects when using objects as save handlers. register_shutdown_function('session_write_close'); }