/** * Get adaptor * @return IAdaptor * @throws InvalidArgumentException */ public function adaptor() { if (DICService::get('db_adaptor') === null) { $manager = function () { if (!Config::exists('db')) { return new Sqlite(); } else { $adaptor_str = Config::get('db'); switch ($adaptor_str) { case 'sqlite': return new Sqlite(); case 'mysql': return new Mysql(); default: if (class_exists($adaptor_str)) { return new $adaptor_str(); } else { throw new InvalidArgumentException("DB adaptor `{$adaptor_str}` is not exists"); } } } }; DICService::set('db_adaptor', $manager); } return DICService::get('db_adaptor'); }
/** * Constructor */ public function __construct($code) { if (DICService::get('captcha_render') === null) { $this->builder = $this->create($code); } else { $this->builder = DICService::get('captcha_render')->create($code); } }
/** * Get manager * * @return DateTimeManager */ protected function date() { if (DICService::get(self::$manager) === null) { $manager = function () { return new DateTimeManager(); }; DICService::set(self::$manager, $manager); } return DICService::get(self::$manager); }
/** * Get manager * * @return UserGroupManager */ private static function getManager() { if (DICService::get(self::$manager) === null) { $manager = function () { return new UserGroupManager(); }; DICService::set(self::$manager, $manager); } return DICService::get(self::$manager); }
/** * Return news link manager * * @return NewsCategoryLinkManager */ private static function getManager() { if (DICService::get(self::$manager) === null) { $manager = function () { return new NewsCategoryLinkManager(); }; DICService::set(self::$manager, $manager); } return DICService::get(self::$manager); }
/** * Return buffer * * @return Buffer */ public function buffer() { if (DICService::get('buffer') === null) { $manager = function () { return new Buffer(); }; DICService::set('buffer', $manager); } return DICService::get('buffer'); }
/** * Return migration manager * * @param string $package * @param string $service * @return Manager\MigrateManager */ public function migrate($package, $service) { if (DICService::get('migration') === null) { $manager = function () use($package, $service) { new MigrateManager($package, $service); }; DICService::set('migration', $manager); } return DICService::get('migration'); }
/** * Get filesystem manager * * @return IFileSystemManager */ protected function filesystem() { $name = 'filesystem'; if (DICService::get($name) === null) { $manager = function () { return new FileSystemManager(); }; DICService::set($name, $manager); } return DICService::get($name); }
function it_deleteSearchIndex(ZendSearchManager $zendsearch) { $zendsearch_ptr = function () use($zendsearch) { $str = Argument::type('string'); $zendsearch->delete($str)->shouldBeCalled()->willReturn(null); return $zendsearch->getWrappedObject(); }; DICService::update('zend_search', $zendsearch_ptr); $this->deleteSearchIndex(1); DICService::delete('zend_search'); }
/** * get console manager * @return ConsoleController */ protected function console() { $name = 'console'; if (DICService::get($name) === null) { $manager = function () { return new ConsoleController(); }; DICService::set($name, $manager); } return DICService::get($name); }
/** * Get string manager * * @return StringManager */ protected function string() { $name = 'string'; if (DICService::get($name) === null) { $manager = function () { return new StringManager(); }; DICService::set($name, $manager); } return DICService::get($name); }
/** * Get logger manager * * @param string $name * @return \Monolog\Logger */ public function log($name = 'default') { $service = 'logger'; if (DICService::get($service) === null) { $manager = function () { return new LoggerManager(); }; DICService::set($service, $manager); } return DICService::get($service)->get($name); }
/** * Get mutex manager * @return IMutexManager */ protected function mutex() { $name = 'mutex'; if (DICService::get($name) === null) { $manager = function () { return new MutexManager(); }; DICService::set($name, $manager); } return DICService::get($name); }
protected function error() { $name = 'error'; if (DICService::get($name) === null) { $manager = function () { return new ErrorManager(); }; DICService::set($name, $manager); } return DICService::get($name); }
/** * Return flash manager * * @return Session */ public function session() { $key = 'session'; if (DICService::get($key) === null) { $manager = function () { return new Session($this->request()); }; DICService::set($key, $manager); } return DICService::get($key); }
/** * Get transaction manager * * @return TransactionManager */ public function transaction() { $key = 'transaction'; if (DICService::get($key) === null) { $manager = function () { return new TransactionManager($this->db()); }; DICService::set($key, $manager); } return DICService::get($key); }
/** * Return error manager * * @return \BX\Config\IConfigManager */ protected function config() { $name = 'config'; if (DICService::get($name) === null) { $manager = function () { return new ConfigManager(); }; DICService::set($name, $manager); } return DICService::get($name); }
/** * Return render exception * * @return RenderException */ private function getRenderException() { $key = 'render_exception'; if (DICService::get($key) === null) { $manager = function () { return new RenderException(); }; DICService::set($key, $manager); } return DICService::get($key); }
/** * Get manager * * @return CaptchaManager */ protected function captcha() { $name = 'captcha'; if (DICService::get($name) === null) { $manager = function () { return new CaptchaManager(); }; DICService::set($name, $manager); } return DICService::get($name); }
/** * Get engine manager * * @return EngineManager */ protected function engine() { $name = 'render'; if (DICService::get($name) === null) { $manager = function () { return new EngineManager(); }; DICService::set($name, $manager); } return DICService::get($name); }
/** * Get event manager * @return EventManager */ private function event() { $name = 'event'; if (DICService::get($name) === null) { $manager = function () { return new EventManager(); }; DICService::set($name, $manager); } return DICService::get($name); }
/** * Get search manager * * @return ZendSearchManager */ public function zendsearch() { $name = 'zend_search'; if (DICService::get($name) === null) { $manager = function () { return new ZendSearchManager(); }; DICService::set($name, $manager); } return DICService::get($name); }
/** * Get counter manager * * @return CounterManager */ protected function getManager() { $name = 'counter'; if (DICService::get($name) === null) { $manager = function () { return new CounterManager(); }; DICService::set($name, $manager); } return DICService::get($name); }
/** * Return error manager * * @return BX\Error\ErrorManager */ private static function getManager() { $name = 'error'; if (DICService::get($name) === null) { $manager = function () { return new ErrorManager(); }; DICService::set($name, $manager); } return DICService::get($name); }
/** * Get translator * * @return TranslateManager */ protected function translator() { $name = 'translate'; if (DICService::get($name) === null) { $manager = function () { return new TranslateManager(); }; DICService::set($name, $manager); } return DICService::get($name); }
/** * Return pdo object * * @return \PDO */ public function pdo() { if (DICService::get('pdo') === null) { $ptr = function () { $dsn = $this->config()->exists('pdo', 'dsn') ? $this->config()->get('pdo', 'dsn') : 'sqlite:memory'; $username = $this->config()->exists('pdo', 'username') ? $this->config()->get('pdo', 'username') : ''; $passwd = $this->config()->exists('pdo', 'passwd') ? $this->config()->get('pdo', 'passwd') : ''; $options = $this->config()->exists('pdo', 'options') ? $this->config()->get('pdo', 'options') : []; return new \PDO($dsn, $username, $passwd, $options); }; DICService::set('pdo', $ptr); } return DICService::get('pdo'); }
/** * Get dispatcher * @return Dispatcher */ private function getDispatcher() { $name = 'event_dispatcher'; if (DICService::get($name) === null) { $manager = function () { if ($this->config()->exists('event', 'dispatcher')) { $dispatcher = $this->config()->get('event', 'dispatcher'); $dispatcher = new $dispatcher(); } else { $dispatcher = new Dispatcher(); } return $dispatcher; }; DICService::set($name, $manager); } return DICService::get($name); }
function it_validateAndAfter(EventManager $event, ZendSearchManager $zendsearch, CacheManager $cache) { $zendsearch->delete(Argument::any())->shouldBeCalled(); $event->fire('OnBeforeTestDelete', Argument::any(), true)->shouldBeCalled()->willReturn(true); $event->fire('OnAfterTestDelete', Argument::any(), true)->shouldBeCalled()->willReturn(true); $cache->clearByTags('test')->shouldBeCalled()->willReturn(null); DICService::update('cache', function () use($cache) { return $cache->getWrappedObject(); }); DICService::update('zend_search', function () use($zendsearch) { return $zendsearch->getWrappedObject(); }); DICService::update('event', function () use($event) { return $event->getWrappedObject(); }); $this->validate(); $this->onAfterCommit(); DICService::delete('event'); DICService::delete('zend_search'); DICService::delete('cache'); }
/** * Return fields builder * * @return FieldsHelper */ public function field() { $key = 'fields'; if (DICService::get($key) === null) { $manager = function () { return new FieldsHelper($this->labels()); }; DICService::set($key, $manager); } return DICService::get($key); }
function letgo() { DICService::delete('render'); }