Example #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)));
     }
 }
Example #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));
     }
 }
Example #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()));
     }
 }
Example #4
0
File: Fly.php Project: schpill/thin
 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));
     }
 }
Example #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));
     }
 }
Example #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));
     }
 }
Example #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));
     }
 }
Example #8
0
File: App.php Project: schpill/thin
 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));
     }
 }
Example #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));
     }
 }
Example #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)));
     }
 }
Example #11
0
File: App.php Project: noikiy/inovi
 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)));
     }
 }
Example #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)));
     }
 }
Example #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)));
     }
 }
Example #14
0
File: Eav.php Project: noikiy/inovi
 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)));
     }
 }
Example #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));
     }
 }
Example #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));
     }
 }
Example #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));
     }
 }
Example #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));
     }
 }
Example #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));
     }
 }
Example #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));
     }
 }
Example #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);
     }
 }
Example #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;
     }
 }
Example #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());
         }
     }
 }
Example #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'])]));
     }
 }
Example #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);
     }
 }
Example #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);
     }
 }
Example #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);
     }
 }
Example #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));
     }
 }
Example #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();
     }
 }
Example #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)));
     }
 }