コード例 #1
0
    static mongoc_collection_t *get_collection(Object obj) {
        mongoc_collection_t *collection;

        auto db = obj->o_realProp("db", ObjectData::RealPropUnchecked, "MongoCollection")->toObject();
        auto client = db->o_realProp("client", ObjectData::RealPropUnchecked, "MongoDB")->toObject();
        String db_name = db->o_realProp("db_name", ObjectData::RealPropUnchecked, "MongoDB")->toString();
        String collection_name = obj->o_realProp("name", ObjectData::RealPropUnchecked, "MongoCollection")->toString();

        collection = mongoc_client_get_collection(get_client(client)->get(), db_name.c_str(), collection_name.c_str());
        return collection;
    }
コード例 #2
0
static Variant HHVM_METHOD(Yaf_Controller_Abstract, getViewpath, 
        const String& path)
{
    auto _viewTmp = this_->o_realProp("_view", 
            ObjectData::RealPropUnchecked, "Yaf_Controller_Abstract");
    if (_viewTmp->isNull()) {
        return false;
    }

    Variant output;
    auto _view = _viewTmp->toObject();
    if (Yaf_Common_InstanceOf(_view, String("Yaf_View_Simple"))) {

        auto tpl_dir = _view->o_realProp("_tpl_dir", 
            ObjectData::RealPropUnchecked, "Yaf_View_Simple");
        if (!tpl_dir->isString()) {
            std::string view_dir = g_yaf_local_data.get()->view_directory;
            return Variant(String(view_dir.c_str()));
        }

        return tpl_dir->toString();
    } else {
        Array func = Array::Create();
        func.append(_view);
        func.append(String("getscriptpath"));

        Array params = Array::Create();
        output = vm_call_user_func(func, params);
    }

    return output;
}