public function setUp() { static::$di = new Di(); Di::setDefault(static::$di); putenv('APP_ENV'); unset($_ENV['APP_ENV'], $_SERVER['APP_ENV']); }
public static function register(Di $di) { static::$di = $di; ini_set('session.use_cookies', 0); ini_set('session.cache_limiter', ''); $di->remove('session'); static::$session = null; $di->setShared('session', function () { $default = Config::get('session.default'); $config = Config::get('session.drivers.' . $default); $class = $config['adapter']; $options = $config['options']; $options += Config::get('session.options'); $options['cookies'] += Config::get('cookies'); session_name($options['cookies']['name']); strpos($class, '\\') === false and $class = 'Phwoolcon\\Session\\Adapter\\' . $class; $session = new $class($options); // @codeCoverageIgnoreStart if (!$session instanceof AdapterInterface) { throw new SessionException('Session class should implement ' . AdapterInterface::class); } // @codeCoverageIgnoreEnd return $session; }); }
public static function register(Di $di) { static::$di = $di; static::$config = Config::get('auth'); $di->setShared('auth', function () { $di = static::$di; $config = static::$config; $class = $config['adapter']; $options = $config['options']; strpos($class, '\\') === false and $class = 'Phwoolcon\\Auth\\Adapter\\' . $class; if ($di->has($class)) { $class = $di->getRaw($class); } if (!class_exists($class)) { throw new Exception('Admin auth adapter class should implement ' . AdapterInterface::class); } /* @var Security $hasher */ $hasher = static::$di->getShared('security'); $hasher->setDefaultHash($options['security']['default_hash']); $hasher->setWorkFactor($options['security']['work_factor']); $adapter = new $class($options, $hasher, $di); if (!$adapter instanceof AdapterInterface) { throw new Exception('Auth adapter class should implement ' . AdapterInterface::class); } return $adapter; }); static::addPhwoolconJsOptions(); }
public function setUp() { static::$di = new Di(); Di::setDefault(static::$di); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); }
public static function register(Di $di) { static::$di = $di; $di->remove('payment'); static::$instance = null; $di->setShared('payment', function () { return new static(Config::get('payment')); }); }
public static function setUpBeforeClass() { $basedir = realpath(__DIR__ . '/../../../'); $testdir = $basedir . '/tests'; self::$viewsdir = realpath($testdir . '/views/') . '/'; include_once $basedir . "/vendor/autoload.php"; $di = new DI(); static::$di = $di; }
public static function register(Di $di) { static::$di = $di; $di->remove('counter'); static::$adapter = null; $di->setShared('counter', function () { $default = Config::get('counter.default'); $config = Config::get('counter.drivers.' . $default); $class = $config['adapter']; $options = $config['options']; strpos($class, '\\') === false and $class = 'Phwoolcon\\Util\\Counter\\' . $class; return new $class($options); }); }
public static function setUpBeforeClass() { $basedir = realpath(__DIR__ . '/../../'); $testdir = $basedir . '/tests'; self::$viewsdir = realpath($testdir . '/views/') . '/'; include_once $basedir . "/vendor/autoload.php"; $di = new DI(); $di->set('form', "Logikos\\Forms\\Form"); $di->set('url', function () { $url = new \Phalcon\Mvc\Url(); $url->setBaseUri('/'); return $url; }); static::$di = $di; }
public static function register(Di $di) { static::$di = $di; $di->remove('cache'); static::$cache = null; $di->setShared('cache', function () { $frontend = new Data(['lifetime' => static::TTL_ONE_DAY]); $default = Config::get('cache.default'); $config = Config::get('cache.drivers.' . $default); $class = $config['adapter']; $options = $config['options']; strpos($class, '\\') === false and $class = 'Phalcon\\Cache\\Backend\\' . $class; isset($options['cacheDir']) and $options['cacheDir'] = storagePath($options['cacheDir']) . '/'; /* @var Backend $backend */ $backend = new $class($frontend, $options); return $backend; }); }
public static function register(Di $di) { static::$di = $di; $di->set('Phalcon\\Http\\Cookie', 'Phwoolcon\\Http\\Cookie'); static::$cookies = static::$di->getShared('cookies'); static::$cookies->reset(); static::$options = $options = Config::get('cookies'); static::$cookies->useEncryption($encrypt = $options['encrypt']); $encrypt and static::$di->getShared('crypt')->setKey($options['encrypt_key'])->setPadding(Crypt::PADDING_ZERO); /* @var \Phalcon\Http\Response $response */ if ($response = $di->getShared('response')) { $response->setCookies(static::$cookies); } Events::attach('view:generatePhwoolconJsOptions', function (Event $event) { $options = $event->getData() ?: []; $options['cookies'] = ['domain' => static::$options['domain'], 'path' => static::$options['path']]; $event->setData($options); return $options; }); }
public static function register(Di $di) { static::$di = $di; $di->remove('service'); $di->setShared('service', function () { return new static(Config::get('service')); }); }
public static function register(Di $di) { static::$di = $di; $di->remove('router'); $di->setShared('router', function () { return new static(); }); }
private function __construct() { static::$di = new Di(new DefinitionList([new ArrayDefinition($this->getDefinition()), new RuntimeDefinition()])); }
public static function register(Di $di) { static::$di = $di; static::$runningUnitTest = Config::runningUnitTest(); $di->setShared('view', function () { return new static(Config::get('view')); }); }
/** * Unsets the di container by setting the static variable to null */ public static function unsetDi() { static::$di = null; }
public static function register(Di $di) { static::$di = $di; }
public static function register(Di $di) { static::$di = $di; $di->setShared('i18n', function () { return new static(Config::get('i18n')); }); Events::attach('view:generatePhwoolconJsOptions', function (Event $event) { $options = $event->getData() ?: []; $options['locale'] = static::getCurrentLocale(); $event->setData($options); return $options; }); }
public static function register(Di $di) { static::$di = $di; $di->remove('modelsMetadata'); $di->setShared('modelsMetadata', function () { return new InCache(); }); $di->setShared('dbManager', function () { return new static(Config::get('database')); }); $di->setShared('db', function () { return static::connection(); }); }
public static function run($module) { static::$di = new FactoryDefault(static::$config, static::$paths, $module); $application = new Application(static::$di); echo $application->handle()->getContent(); }