Exemplo 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');
 }
Exemplo 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);
     }
 }
Exemplo n.º 3
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');
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
Arquivo: View.php Projeto: 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');
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
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);
 }
Exemplo n.º 8
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);
 }
Exemplo n.º 9
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);
 }
Exemplo n.º 10
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);
 }
Exemplo n.º 11
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);
 }
Exemplo n.º 12
0
 protected function error()
 {
     $name = 'error';
     if (DICService::get($name) === null) {
         $manager = function () {
             return new ErrorManager();
         };
         DICService::set($name, $manager);
     }
     return DICService::get($name);
 }
Exemplo n.º 13
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);
 }
Exemplo n.º 14
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);
 }
Exemplo 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);
 }
Exemplo n.º 16
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);
 }
Exemplo n.º 17
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);
 }
Exemplo 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);
 }
Exemplo n.º 19
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);
 }
Exemplo n.º 20
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);
 }
Exemplo n.º 21
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);
 }
Exemplo n.º 22
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);
 }
Exemplo n.º 23
0
Arquivo: Error.php Projeto: 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);
 }
Exemplo n.º 24
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);
 }
Exemplo n.º 25
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');
 }
Exemplo n.º 26
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);
 }
Exemplo n.º 27
0
 /**
  * Return search helper
  *
  * @return SearchHelper
  */
 protected function index()
 {
     $key = 'search_helper';
     if (DICService::get($key) === null) {
         $manager = function () {
             return new SearchHelper($this);
         };
         DICService::set($key, $manager);
     }
     return DICService::get($key);
 }
Exemplo n.º 28
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);
 }
Exemplo n.º 29
0
 /**
  * Get manager
  *
  * @return RememberPasswordManager
  */
 private static function getManager()
 {
     if (DICService::get(self::$manager) === null) {
         $manager = function () {
             return new RememberPasswordManager();
         };
         DICService::set(self::$manager, $manager);
     }
     return DICService::get(self::$manager);
 }
Exemplo n.º 30
0
 /**
  * Return column helper
  *
  * @return ColumnHelper
  */
 protected function column()
 {
     $key = 'column_helper';
     if (DICService::get($key) === null) {
         $manager = function () {
             return new ColumnHelper();
         };
         DICService::set($key, $manager);
     }
     return DICService::get($key);
 }