【问题标题】:Smfony2: Getting an error when trying to use translatble behavior extensionSmfony2:尝试使用可翻译行为扩展时出错
【发布时间】:2021-09-13 18:38:28
【问题描述】:

我正在尝试在我的项目中使用可翻译行为,我逐字逐句地按照文档说明如何配置和使用此行为,但出现此错误:

CRITICAL - Uncaught PHP Exception ReflectionException: "Property locale doesn't exist" at C:\wamp\www\Symfony\vendor\gedmo\doctrine-extensions\lib\Gedmo\Translatable\TranslatableListener.php line 296

有人可以帮忙吗? 在此先感谢:)

编辑: 这是第 296 行:

$reflectionProperty = $class->getProperty(self::$configurations[$this->name][$meta->name]['locale']);

【问题讨论】:

  • 你在config.yml打开翻译了吗?
  • 尝试var_dump self::$configurations
  • 当然你的可翻译类中有$locale; 属性?

标签: php symfony


【解决方案1】:

在我的例子中,所需的$locale 字段是在实体的抽象超类中定义的——这基本上没问题,但它不能是private,最多是protected

【讨论】:

    猜你喜欢
    • 2014-02-27
    • 1970-01-01
    • 2021-09-30
    • 1970-01-01
    • 2011-11-26
    • 1970-01-01
    • 2017-06-15
    • 2012-12-30
    • 2014-01-11
    相关资源
    最近更新 更多