skaut / doctrine-nullable-embeddables
此包已被废弃,不再维护。未建议替代包。
Doctrine 2.5+ 中可空嵌入对象的机制
1.1.1
2023-01-15 10:44 UTC
Requires
- php: ^7.0|^8.0
- doctrine/orm: ^2.5
Requires (Dev)
- phpunit/phpcov: ^4.0
- phpunit/phpunit: ^6.0
- satooshi/php-coveralls: ^1.0
This package is auto-updated.
Last update: 2023-02-15 10:59:03 UTC
README
此包作为 Doctrine 2.5+ 中嵌入对象不支持可空值的解决方案。有关此问题的更多信息,请参阅 doctrine/doctrine2。
安装
使用 Composer 是安装 fmasa/doctrine-yaml-annotations 的最佳方式
$ composer require fmasa/doctrine-nullable-embeddables
必须满足以下条件
- 具有可空嵌入对象的属性必须使用
Fmasa\DoctrineNullableEmbeddables\Annotations\Nullable
注解。 - 可空嵌入对象中的每个属性都必须是可空的(或者如果它是嵌入对象,则必须使用
Nullable
注解)
现在您只需注册 Fmasa\DoctrineNullableEmbeddables\Subscriber
即可使用可空嵌入对象
/* @var $annotationReader Doctrine\Common\Annotations\Reader */ /* @var $em Doctrine\ORM\EntityManager */ $evm->addEventSubscriber(new Fmasa\DoctrineNullableEmbeddables\Subscriber($annotationReader));
但我在使用 YAML 进行映射!
请参阅 fmasa/doctrine-yaml-annotations 了解如何使此类扩展与 YAML 映射一起工作。