Esempio n. 1
0
 /**
  * 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');
 }
Esempio n. 2
0
 /**
  * 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);
     }
 }
Esempio n. 3
0
 /**
  * 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);
 }
Esempio n. 4
0
 /**
  * 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);
 }
Esempio n. 5
0
 /**
  * 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);
 }
Esempio n. 6
0
File: View.php Progetto: jarick/bx
 /**
  * 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');
 }
Esempio n. 7
0
 /**
  * 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');
 }
Esempio n. 8
0
 /**
  * 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);
 }
Esempio n. 9
0
 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');
 }
Esempio n. 10
0
 /**
  * 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);
 }
Esempio n. 11
0
 /**
  * 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);
 }
Esempio n. 12
0
 /**
  * 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);
 }
Esempio n. 13
0
 /**
  * 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);
 }
Esempio n. 14
0
 protected function error()
 {
     $name = 'error';
     if (DICService::get($name) === null) {
         $manager = function () {
             return new ErrorManager();
         };
         DICService::set($name, $manager);
     }
     return DICService::get($name);
 }
Esempio n. 15
0
 /**
  * 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);
 }
Esempio n. 16
0
 /**
  * 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);
 }
Esempio n. 17
0
 /**
  * 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);
 }
Esempio n. 18
0
 /**
  * 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);
 }
Esempio n. 19
0
 /**
  * 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);
 }
Esempio n. 20
0
 /**
  * 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);
 }
Esempio n. 21
0
 /**
  * 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);
 }
Esempio n. 22
0
 /**
  * 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);
 }
Esempio n. 23
0
 /**
  * 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);
 }
Esempio n. 24
0
File: Error.php Progetto: jarick/bx
 /**
  * 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);
 }
Esempio n. 25
0
 /**
  * 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);
 }
Esempio n. 26
0
 /**
  * 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');
 }
Esempio n. 27
0
 /**
  * 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);
 }
Esempio n. 28
0
 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');
 }
Esempio n. 29
0
 /**
  * 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);
 }
Esempio n. 30
0
 function letgo()
 {
     DICService::delete('render');
 }