我已经创建了自己的服务,我需要注入doctrine EntityManager,但是我没有看到__construct()
在我的服务上调用它,并且注入不起作用.
这是代码和配置:
<?php
namespace Test\CommonBundle\Services;
use Doctrine\ORM\EntityManager;
class UserService {
/**
*
* @var EntityManager
*/
protected $em;
public function __constructor(EntityManager $entityManager)
{
var_dump($entityManager);
exit(); // I've never saw it happen, looks like constructor never called
$this->em = $entityManager;
}
public function getUser($userId){
var_dump($this->em ); // outputs null
}
}
Run Code Online (Sandbox Code Playgroud)
这是services.yml
我的捆绑
services:
test.common.userservice:
class: Test\CommonBundle\Services\UserService
arguments:
entityManager: "@doctrine.orm.entity_manager"
Run Code Online (Sandbox Code Playgroud)
我已经config.yml
在我的应用程序中导入了.yml
imports:
# a few lines skipped, not relevant here, i think
- { resource: …
Run Code Online (Sandbox Code Playgroud) 我有使用ndk-build工具编译cpp文件的问题(带有cygwin的Windows 7)当我尝试使用#include编译cpp文件时出现错误:
jni/native.cpp:5:20: error: iostream: No such file or directory
Run Code Online (Sandbox Code Playgroud)
这是我的cpp文件:
#include <jni.h>
#include <string.h>
#include <stdio.h>
#include <android/log.h>
#include <iostream>
#define DEBUG_TAG "NDK_SampleActivity"
#define LOG_TAG "hellojni"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
#ifdef __cplusplus
extern "C" {
#endif
void Java_com_test_ndk_SampleActivity_helloLog(JNIEnv* env, jobject thisobj, jstring logThis)
{
jboolean isCopy;
const char * szLogThis = env->GetStringUTFChars(logThis, &isCopy);
__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:LC: [%s]", szLogThis);
env->ReleaseStringUTFChars(logThis, szLogThis);
}
#ifdef __cplusplus
}
#endif
Run Code Online (Sandbox Code Playgroud)
这是我的Android.mk文件:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
APP_STL:=stlport_static
LOCAL_LDLIBS := -llog
LOCAL_MODULE …
Run Code Online (Sandbox Code Playgroud) 我正在使用 predis(如果有什么区别的话,可以使用 laravel)php 客户端来与 Redis 一起工作。
我需要从 Redis 获取与特定前缀匹配的所有键,我这样做:
$keys = [];
foreach (new Iterator\Keyspace($this->redis(), Cache::KEY_PREFIX.'*') as $key) {
$keys[] = $rate_key;
}
Run Code Online (Sandbox Code Playgroud)
使用这些键完成操作后,操作会重复 - 我将在循环中再次获取这些键。我注意到经过几次迭代后,某些键未包含在 $keys 数组中。
最奇怪的是,消失的键在下一次迭代中永远不会出现。重新启动 php 进程(它是一个守护进程)可以解决该问题。
我使用 Redis 3.0.2 与 Predis 1.0 和 PHP 5.4
PS 在按键循环中,我更改了其中一些按键的值。不过,我不会删除任何键。