Ejemplo n.º 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)));
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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()));
     }
 }
Ejemplo n.º 4
0
Archivo: Fly.php Proyecto: 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));
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 8
0
Archivo: App.php Proyecto: 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));
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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)));
     }
 }
Ejemplo n.º 11
0
Archivo: App.php Proyecto: 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)));
     }
 }
Ejemplo n.º 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)));
     }
 }
Ejemplo n.º 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)));
     }
 }
Ejemplo n.º 14
0
Archivo: Eav.php Proyecto: 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)));
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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());
         }
     }
 }
Ejemplo n.º 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'])]));
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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)));
     }
 }