【发布时间】:2019-11-21 12:33:35
【问题描述】:
我正在使用 Symfony 4.3.8,但找不到任何关于这些弃用的信息:
不推荐使用用户:不推荐使用创建 Doctrine\ORM\Mapping\UnderscoreNamingStrategy 而不使其知道数字的做法,并将在 Doctrine ORM 3.0 中删除。
不建议使用创建 Doctrine\ORM\Mapping\UnderscoreNamingStrategy 而不使其知道数字,并将在 Doctrine ORM 3.0 中删除。
我在stacktrace中搜索并找到了这个:
class UnderscoreNamingStrategy implements NamingStrategy
{
private const DEFAULT_PATTERN = '/(?<=[a-z])([A-Z])/';
private const NUMBER_AWARE_PATTERN = '/(?<=[a-z0-9])([A-Z])/';
/**
* Underscore naming strategy construct.
*
* @param int $case CASE_LOWER | CASE_UPPER
*/
public function __construct($case = CASE_LOWER, bool $numberAware = false)
{
if (! $numberAware) {
@trigger_error(
'Creating ' . self::class . ' without making it number aware is deprecated and will be removed in Doctrine ORM 3.0.',
E_USER_DEPRECATED
);
}
$this->case = $case;
$this->pattern = $numberAware ? self::NUMBER_AWARE_PATTERN : self::DEFAULT_PATTERN;
}
在这个类中,构造函数总是在没有参数的情况下被调用,所以 $numberAware 总是 false。
这个类在 Symfony 依赖注入自动生成的文件中被调用,所以我不能“编辑”它...
我想可能是在教义.yaml 中:
doctrine:
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
但我还没有找到任何允许数字感知的选项:(
【问题讨论】:
-
只需创建一个新的 4.4.0(刚刚发布,是的)项目,并且教义.yaml 中包含“naming_strategy:教义.orm.naming_strategy.underscore_number_aware”。尝试调整你的。
标签: symfony doctrine-orm doctrine