Пример #1
0
 public static function instance($ns, $table)
 {
     $key = sha1(serialize(func_get_args()));
     $has = Instance::has('Entitydb', $key);
     if (true === $has) {
         return Instance::get('Entitydb', $key);
     } else {
         return Instance::make('Entitydb', $key, with(new self($ns, $table)));
     }
 }
Пример #2
0
 public static function instance(Database $model)
 {
     $key = sha1($model->db . APPLICATION_ENV . $model->table);
     $has = Instance::has('DbjsonSession', $key);
     if (true === $has) {
         return Instance::get('DbjsonSession', $key);
     } else {
         return Instance::make('DbjsonSession', $key, new self($model));
     }
 }
Пример #3
0
 public static function app($name)
 {
     $key = sha1('tool' . $name);
     $has = Instance::has('tool', $key);
     if (true === $has) {
         return Instance::get('tool', $key);
     } else {
         return Instance::make('tool', $key, with(new static()));
     }
 }
Пример #4
0
 public static function instance($name, $data = [])
 {
     $key = sha1('Fly.' . $name);
     $has = Instance::has('Fly', $key);
     if (true === $has) {
         return Instance::get('Fly', $key);
     } else {
         return Instance::make('Fly', $key, new self($data));
     }
 }
Пример #5
0
 public static function instance(Db $db, Container $row)
 {
     $key = sha1($db->db . $db->table . serialize($row->assoc()));
     $has = Instance::has('DbjsonModel', $key);
     if (true === $has) {
         return Instance::get('DbjsonModel', $key);
     } else {
         return Instance::make('DbjsonModel', $key, new self($db, $row));
     }
 }
Пример #6
0
 public static function instance(Database $model)
 {
     $key = sha1($model->db . $model->table);
     $has = Instance::has('NosqlCrud', $key);
     if (true === $has) {
         return Instance::get('NosqlCrud', $key);
     } else {
         return Instance::make('NosqlCrud', $key, new self($model));
     }
 }
Пример #7
0
 public static function instance($model)
 {
     $key = sha1($model->collection);
     $has = Instance::has('S3Observer', $key);
     if (true === $has) {
         return Instance::get('S3Observer', $key);
     } else {
         return Instance::make('S3Observer', $key, new self($model));
     }
 }
Пример #8
0
 public static function instance($app = 'core')
 {
     $key = sha1($app);
     $has = Instance::has('App', $key);
     if (true === $has) {
         return Instance::get('App', $key);
     } else {
         return Instance::make('App', $key, new self($app));
     }
 }
Пример #9
0
 public static function instance($collection)
 {
     $key = sha1($collection);
     $has = Instance::has('nosqlStore', $key);
     if (true === $has) {
         return Instance::get('nosqlStore', $key);
     } else {
         return Instance::make('nosqlStore', $key, new self($collection));
     }
 }
Пример #10
0
 public static function instance(Database $model)
 {
     $key = sha1($model->database . $model->table);
     $has = Instance::has('DatabaseValidator', $key);
     if (true === $has) {
         return Instance::get('DatabaseValidator', $key);
     } else {
         return Instance::make('DatabaseValidator', $key, with(new self($model)));
     }
 }
Пример #11
0
 public static function instance($app = 'core')
 {
     $key = sha1(serialize(func_get_args()));
     $has = Instance::has('App', $key);
     if (true === $has) {
         return Instance::get('App', $key);
     } else {
         return Instance::make('App', $key, with(new self($app)));
     }
 }
Пример #12
0
 public static function instance($namespace, $ttl = 3600)
 {
     $key = sha1($namespace);
     $has = Instance::has('RedisSession', $key);
     if (true === $has) {
         return Instance::get('RedisSession', $key);
     } else {
         return Instance::make('RedisSession', $key, with(new self($namespace, $ttl)));
     }
 }
Пример #13
0
 public static function instance($namespace, $entity)
 {
     $key = sha1($namespace . $entity);
     $has = Instance::has('mongonode', $key);
     if (true === $has) {
         return Instance::get('mongonode', $key);
     } else {
         return Instance::make('mongonode', $key, with(new self($entity, $namespace)));
     }
 }
Пример #14
0
 public static function instance($db, $table, $timestamps = true)
 {
     $key = sha1(serialize(func_get_args()));
     $has = Instance::has('Eav', $key);
     if (true === $has) {
         return Instance::get('Eav', $key);
     } else {
         return Instance::make('Eav', $key, with(new self($db, $table, $timestamps)));
     }
 }
Пример #15
0
 public static function instance($ns)
 {
     $key = sha1($ns);
     $has = Instance::has('MliteLog', $key);
     if (true === $has) {
         return Instance::get('MliteLog', $key);
     } else {
         return Instance::make('MliteLog', $key, new self($ns));
     }
 }
Пример #16
0
 public static function instance($ns = 'core')
 {
     $args = func_get_args();
     $key = sha1(serialize($args));
     $has = Instance::has('Context', $key);
     if (true === $has) {
         return Instance::get('Context', $key);
     } else {
         return Instance::make('Context', $key, new self($ns));
     }
 }
Пример #17
0
 public static function instance($user = null)
 {
     $args = func_get_args();
     $key = sha1(serialize($args));
     $has = Instance::has('Auth', $key);
     if (true === $has) {
         return Instance::get('Auth', $key);
     } else {
         return Instance::make('Auth', $key, new self($user));
     }
 }
Пример #18
0
 public static function instance($collection)
 {
     $args = func_get_args();
     $key = sha1(serialize($args));
     $has = Instance::has('rawStore', $key);
     if (true === $has) {
         return Instance::get('rawStore', $key);
     } else {
         return Instance::make('rawStore', $key, new self($collection));
     }
 }
Пример #19
0
 public static function instance($db, $table)
 {
     $args = func_get_args();
     $key = sha1(serialize($args));
     $has = Instance::has('FastDb', $key);
     if (true === $has) {
         return Instance::get('FastDb', $key);
     } else {
         return Instance::make('FastDb', $key, new self($db, $table));
     }
 }
Пример #20
0
 public static function connect()
 {
     $dbFile = Config::get('directory.store', STORAGE_PATH) . DS . 'kvs.db';
     self::init($dbFile);
     $key = sha1('KVSLITE');
     $has = Instance::has('KvsLite', $key);
     if (true === $has) {
         return Instance::get('KvsLite', $key);
     } else {
         return Instance::make('KvsLite', $key, new PDO('sqlite:' . $dbFile));
     }
 }
Пример #21
0
 public static function instanceDb($ns)
 {
     $key = sha1($ns);
     $has = Instance::has('DbredisCachingDb', $key);
     if (true === $has) {
         return Instance::get('DbredisCachingDb', $key);
     } else {
         $i = new self($ns);
         list($db, $table) = explode('.', $ns, 2);
         $i = $i->changeCollection("{$db}.caching")->changeNs($table);
         return Instance::make('DbredisCachingDb', $key, $i);
     }
 }
Пример #22
0
 public static function connect()
 {
     $dsn = 'mysql:dbname=' . Config::get('mysql.dbname', ConfigApp::get('database.dbname', SITE_NAME)) . ';host=' . Config::get('mysql.host', ConfigApp::get('database.host', 'localhost'));
     $user = Config::get('mysql.username', ConfigApp::get('database.username', 'root'));
     $password = Config::get('mysql.password', ConfigApp::get('database.password', ''));
     $key = sha1('KVSMYSQL');
     $has = Instance::has('KvsMysql', $key);
     if (true === $has) {
         $instance = Instance::get('KvsMysql', $key);
         self::init($instance);
         return $instance;
     } else {
         $instance = Instance::make('KvsMysql', $key, new PDO($dsn, $user, $password));
         self::init($instance);
         return $instance;
     }
 }
Пример #23
0
 public static function instance()
 {
     $args = func_get_args();
     $key = sha1(serialize($args));
     $has = Instance::has('Dbjson', $key);
     if (true === $has) {
         return Instance::get('Dbjson', $key);
     } else {
         if (count($args) == 2) {
             list($db, $table) = $args;
             return Instance::make('Dbjson', $key, new self($db, $table));
         } elseif (count($args) == 3) {
             list($db, $table, $path) = $args;
             return Instance::make('Dbjson', $key, new self($db, $table, $path));
         } else {
             return Instance::make('Dbjson', $key, new self());
         }
     }
 }
Пример #24
0
 function es()
 {
     $has = Instance::has('elasticSearch', SITE_NAME . '_es');
     if (true === $has) {
         return Instance::get('elasticSearch', SITE_NAME . '_es');
     } else {
         return Instance::make('elasticSearch', SITE_NAME . '_es', new ESC(['hosts' => Config::get('elasticsearch.hosts', ['127.0.0.1:9200'])]));
     }
 }
Пример #25
0
 public function cache()
 {
     $has = Instance::has('fileDbCache', sha1($this->collection));
     if (true === $has) {
         return Instance::get('fileDbCache', sha1($this->collection));
     } else {
         $instance = Caching::instance($this->collection);
         return Instance::make('fileDbCache', sha1($this->collection), $instance);
     }
 }
Пример #26
0
 public function cache()
 {
     $has = Instance::has('fastDbCache', sha1($this->collection));
     if (true === $has) {
         return Instance::get('fastDbCache', sha1($this->collection));
     } else {
         $instance = new Client(['host' => 'localhost', 'port' => 6379, 'database' => 3]);
         return Instance::make('fastDbCache', sha1($this->collection), $instance);
     }
 }
Пример #27
0
 public function cache()
 {
     $has = Instance::has('MysqlDbCache', sha1($this->db . $this->table));
     if (true === $has) {
         return Instance::get('MysqlDbCache', sha1($this->db . $this->table));
     } else {
         $instance = new Caching($this->collection);
         return Instance::make('MysqlDbCache', sha1($this->db . $this->table), $instance);
     }
 }
Пример #28
0
 public static function instance($db, $table, $host = 'localhost', $username = '******', $password = '')
 {
     $key = sha1(serialize(func_get_args()));
     $has = Instance::has('Database', $key);
     if (true === $has) {
         return Instance::get('Database', $key);
     } else {
         return Instance::make('Database', $key, new self($db, $table, $host, $username, $password));
     }
 }
Пример #29
0
 public function cache()
 {
     $method = Config::get($this->db . '.cache', Config::get('redis.enabled', false) ? 'redis' : 'jcache');
     if ($method == 'redis') {
         $servers = Config::get('redis.cluster', ['tcp://127.0.0.1:6379']);
         $has = Instance::has('DbjsonRedisCluster', sha1(serialize($servers)));
         if (true === $has) {
             return Instance::get('DbjsonRedisCluster', sha1(serialize($servers)));
         } else {
             $instance = new \Predis\Client(['host' => 'localhost', 'port' => 6379, 'database' => 6]);
             return Instance::make('DbjsonRedisCluster', sha1(serialize($servers)), $instance);
         }
     } else {
         return $method();
     }
 }
Пример #30
0
 function instance($class, $params = array())
 {
     $key = sha1($class . serialize($params));
     $has = Instance::has('helper_' . $class, $key);
     if (true === $has) {
         return Instance::get('helper_' . $class, $key);
     } else {
         return Instance::make('helper_' . $class, $key, with(Utils::getInstance($class, $params)));
     }
 }