原则2.5。尝试使用
手动生成代理时doctrine orm:generate-proxies
抛出异常:
[学说\ ORM \ ORMException]
无法实例化自定义生成器:MyBundle \ MyCustomGenerator
我定义了一个可以正常工作的自定义生成器:
/**
* @ORM\Column(type="string")
* @ORM\Id
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class="MyBundle\MyCustomGenerator")
*/
protected $id;
此外,手动实例化生成器,如
$a = new MyBundle\MyCustomGenerator();
的工作原理。但由于某种原因,Doctrine控制台抛出了上述异常。
我试图调试并检查发生了什么
ClassMetadataFactory
$definition['class']
中定义了例外情况。我检查MyBundle\MyCustomGenerator
存储了我的自定义生成器的名称:cli-config.php
。但是,学说还是找不到这个班级
我想我应该将use MyBundle
的定义添加为completeIdGeneratorMapping
,use MyBundle\MyCustomGenerator
或//Create below methods into the Activity which contains RecyclerView.
private void createRecyclerView() {
final RecyclerView recyclerView = (RecyclerView)findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
MyAdapter myAdapter=new MyAdapter(dataAray,MianActivity.this);
recyclerView.setAdapter(myAdapter);
recyclerView.setItemAnimator(new DefaultItemAnimator());
setRecyclerViewClickListner(recyclerView);
}
private void setRecyclerViewClickListner(RecyclerView recyclerView){
final GestureDetector gestureDetector = new GestureDetector(MainActivity.this,new GestureDetector.SimpleOnGestureListener() {
@Override public boolean onSingleTapUp(MotionEvent e) {
return true;
}
});
recyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
@Override
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
View child =recyclerView.findChildViewUnder(motionEvent.getX(),motionEvent.getY());
if(child!=null && gestureDetector.onTouchEvent(motionEvent)){
int position=recyclerView.getChildLayoutPosition(child);
String name=itemArray.get(position).name;
return true;
}
@Override
public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean b) {
}
});
}
,但它不起作用 - 仍然会抛出相同的异常。
任何想法如何让Doctrine控制台知道我的自定义ID生成器?
答案 0 :(得分:0)
不确定它会有所帮助或仍然需要帮助,但请尝试此操作
@ORM \ CustomIdGenerator(类=" \ MyBundle \ MyCustomGenerator&#34)
即将起始斜杠添加到类定义
答案 1 :(得分:0)
在我的情况下,有一些语法错误阻止了类正确自动加载。
一旦我在自定义生成器类中解决了这些问题,那么Doctrine就能找到该类。我希望异常抛出是语法错误,但它没有,也许是因为该类只是通过Annotation使用。
然而,正如你所说,你能够通过其他方式实例化你的课程,所以你可能没有和我一样的问题,但也许这可以帮助其他人!