/** * Set up test vars * * @return void * @author Dan Cox */ public function setUp() { $di = new DI(); $di->setShared('output', new Output()); $di->setShared('input', new Input()); $this->helpers = new Helpers($di); }
public function setUp() { $this->di = \Phalcon\DI::getDefault(); $this->di->setShared('environment', function () { return \Vegas\Constants::TEST_ENV; }); $this->di->setShared('view', function () { return 'fake-view'; }); }
/** * @param DI $di */ public function registerServices($di) { //Registering a dispatcher $di->setShared('dispatcher', function () use($di) { $dispatcher = new Dispatcher(); $dispatcher->setDefaultNamespace("Admin"); $eventsManager = $di->getShared('eventsManager'); $eventsManager->attach('dispatch', new AdminSecurity($di)); $dispatcher->setEventsManager($eventsManager); return $dispatcher; }); $auto_admin = new \AutoAdmin\Module(); $auto_admin->registerServices($di); $di->setShared('admin_views_dir', function () { return ADMINROOT . '/views/'; }); $di->setShared('session', function () { $session = new Session(); $session->start(); return $session; }); $di->setShared('config', function () use($di) { $configFront = (require COREROOT . '/app/config/config.php'); $configBack = (require ADMINROOT . '/config/config.php'); $configFront->merge($configBack); return $configFront; }); }
/** * Initialize testing object * * @uses Auth * @uses \ReflectionClass */ public function setUp() { $this->di = new FactoryDefault(); $this->di->reset(); // Setup DI $this->di = new DI(); $this->di->setShared('session', function () { $session = new \Phalcon\Session\Adapter\Files(); $session->start(); return $session; }); $this->di->set('tag', function () { $tag = new \Phalcon\Tag(); return $tag; }); $this->di->set('escaper', function () { $escaper = new \Phalcon\Escaper(); return $escaper; }); DI::setDefault($this->di); $this->reflection = new \ReflectionClass('ULogin\\Auth'); $this->auth = new Auth(); }
/** * @param DI $di */ public function registerServices($di) { $this->registerAutoloaders(); $di->setShared('session', function () { $session = new \Phalcon\Session\Adapter\Files(); $session->start(); return $session; }); $di->set('view', function () use($di) { $view = new View(); $view->setViewsDir(MINI_ADMIN_ROOT . '/views/'); return $view; }); }
/** * @param Router|null $router * @param Url|null $url */ public function __construct(Router $router = null, Url $url = null) { $di = new DI(); $di->setShared('request', new PhalconRequest()); if ($router instanceof PhalconRouterInterface) { $this->router = $router; } elseif ($router === null) { $this->router = new Router(); $this->router->clear(); } else { throw new Exception\RuntimeException('Router has to be an instance of RouterInterface'); } $this->router->setDI($di); $di->setShared('router', $this->router); if ($url instanceof UrlInterface) { $this->url = $url; } elseif ($url === null) { $this->url = new Url(); $this->url->setBaseUri('/'); } else { throw new Exception\RuntimeException('Url has to be an instance of UrlInterface'); } $this->url->setDI($di); }
/** * Init engine. * * @param DI $di Dependency Injection. * * @return void */ protected function _initEngine($di) { $di->setShared('transactions', function () { $manager = new TxManager(); return $manager->setDbService("dbMaster"); }); }
/** * Registration services for specific module * @param \Phalcon\DI $di * @access public * @return mixed */ public function registerServices($di) { // Dispatch register $di->set('dispatcher', function () use($di) { $eventsManager = $di->getShared('eventsManager'); $eventsManager->attach('dispatch:beforeException', new \Plugins\Dispatcher\NotFoundPlugin()); $dispatcher = new \Phalcon\Mvc\Dispatcher(); $dispatcher->setEventsManager($eventsManager); $dispatcher->setDefaultNamespace('Modules\\' . self::MODULE . '\\Controllers'); return $dispatcher; }, true); // Registration of component representations (Views) $di->set('view', function () { $view = new View(); $view->setViewsDir($this->_config['application']['viewsBack'])->setMainView('auth-layout')->setPartialsDir('partials'); return $view; }); require_once APP_PATH . '/Modules/' . self::MODULE . '/config/services.php'; // call profiler if ($this->_config->database->profiler === true) { new \Plugins\Debugger\Develop($di); } if (APPLICATION_ENV == 'development') { // share Fabfuel topbar $profiler = new \Fabfuel\Prophiler\Profiler(); $di->setShared('profiler', $profiler); $pluginManager = new \Fabfuel\Prophiler\Plugin\Manager\Phalcon($profiler); $pluginManager->register(); // add toolbar in your basic BaseController } return; }
/** * Init session. * * @param DI $di Dependency Injection. * @param Config $config Config object. * * @return SessionAdapter */ protected function _initSession($di, $config) { $session = new \Phalcon\Session\Adapter\Redis(['path' => "tcp://127.0.0.1:6379?weight=1", 'persistent' => false, 'lifetime' => 3600, 'prefix' => '_haraapp_']); $session->start(); $di->setShared('session', $session); return $session; }
private function buildContainer() { $container = new Container(); $container->setShared('service_container', $container); $container->setShared('config', $this->config); foreach ($this->getServices() as $name => $definition) { $container->setShared($name, $definition); } return $container; }
/** * Init engine. * * @param DI $di Dependency Injection. * * @return void */ protected function _initEngine($di) { foreach ($di->get('registry')->modules as $module) { // Initialize module api. $di->setShared(strtolower($module), function () use($module, $di) { return new ApiInjector($module, $di); }); } $di->setShared('transactions', function () { return new TxManager(); }); $di->setShared('assets', new AssetsManager($di)); $di->setShared('widgets', new Catalog()); }
/** * Register configurations * @param Phalcon\DI $di */ private function registerConfigurations($di) { $di->setShared('config', function () { return new \Phalcon\Config\Adapter\Ini(self::CONFIG_FILE); }); }
/** * Init session. * * @param DI $di Dependency Injection. * @param Config $config Config object. * * @return SessionAdapter */ protected function _initSession($di, $config) { $session = new PhSessionFiles(); $session->start(); $di->setShared('session', $session); return $session; }