定制 npo/doctrine-extension 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

npo/doctrine-extension

最新稳定版本:2.1

Composer 安装命令:

composer require npo/doctrine-extension

包简介

Library containing helper classes and services Doctrine

README 文档

README

When it comes to orphan removal in Doctrine 2.x, DDD is not made possible as the orphan removal feature relies on the PersistentCollection class. However, this package enables support for orphan removal without the use of the PersistentCollection class, thus making it DDD compliant.

Note:

The data structure containing (the one replacing the PersistentCollection) the entities must be an iterable (lookup https://www.php.net/manual/en/language.types.iterable.php)

Installation

composer require npo/doctrine-extension

Add the bundle to config/bundles.php:

NpoMessage\DoctrineExtension\DoctrineExtensionBundle::class => ['all' => true],

Usage

Configure the properties that are set for orphan removal in the config/packages/npo_doctrine_extension.yaml file. For example:

#config/packages/npo_doctrine_extension.yaml
npo_doctrine_extension:
  orphan_removal:
    App\Domain\Entity\User:
        notes:
            class: App\Domain\Entity\Note
            mapped_by: user
        images:
            class: App\Domain\Entity\Image
            id: guid
            mapped_by: user
    App\Domain\Entity\Post:
        images:
            method_name: giveMeTheImages
            class: App\Domain\Entity\Image
            mapped_by: post

id

By default, the id is extracted using class metadata. However, you can specify which id to use by passing the id property.

method_name

By default, the Symfony\Component\PropertyAccess\PropertyAccessorInterface is used to extract the values. The PropertyAccessorInterface calls methods that are prefixed by either get, is, or has by default (lookup https://symfony.com/doc/current/components/property_access.html#accessing-public-properties). Nonetheless, you can specify the method name to be used by passing the method_name property.

统计信息

  • 总下载量: 6k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2023-08-24