dpd20130 2015-08-16 07:55
浏览 96

Doctrine orm:生成代理抛出“无法实例化自定义生成器”

Doctrine 2.5. When trying to generate proxies manually with

doctrine orm:generate-proxies

an exception is thrown:

[Doctrine\ORM\ORMException]
Can't instantiate custom generator : MyBundle\MyCustomGenerator

I have a custom generator defined which works correctly:

/**
 * @ORM\Column(type="string")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="CUSTOM")
 * @ORM\CustomIdGenerator(class="MyBundle\MyCustomGenerator")
 */
protected $id;

Also, instantiating the generator manually, like

$a = new MyBundle\MyCustomGenerator();

works. But for a reason the Doctrine Console throws the above exception.

I've tried to debug and check what's going on.
The exception is defined in completeIdGeneratorMapping of ClassMetadataFactory. I checked that $definition['class'] stores the name of my custom generator: MyBundle\MyCustomGenerator. But still, Doctrine can't find the class.
Thought I should add the definition to cli-config.php as explained in the doc, with use MyBundle or use MyBundle\MyCustomGenerator, but it did not work - still the same exception was thrown.

Any ideas how should I make the Doctrine Console aware of my custom ID generator?

  • 写回答

2条回答 默认 最新

  • dti3914 2016-06-09 11:31
    关注

    Not sure it will help or still need help, but try this

    @ORM\CustomIdGenerator(class="\MyBundle\MyCustomGenerator")

    ie add starting slash to class definition

    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站