定制 monro/doctrine-nullable-embedabbles 二次开发

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

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

monro/doctrine-nullable-embedabbles

Composer 安装命令:

composer require monro/doctrine-nullable-embedabbles

包简介

Workarround to the issues related of using Doctrine with embedabbles relations where the relation can be null. If the object is null doctrine would instanciate it with all the properties to null, this library will fix it to set it to null.

README 文档

README

Build Status Coverage Status

Why

The purpose of this library is to fix a known bug on doctrine where you cannot have nullable embeddables.

The issue is the following:

Given a class "A" that has an ORM relation with an embedded "B" that could be null
When an instance of "A" is loaded from DB and "B" is null
Then an instance of "B" is created with all the values to null and assigned to the property "B" of "A"

The behaviour of this library will be the following:

Given a class "A" that has an ORM relation with an embedded "B" that could be null
When an instance of "A" is loaded from DB and "B" is null
Then the property "B" of "A" is set to null

For now it only works with yml files as is what we use, if you think that will be useful to have it for XML or annotations, please open an issue

Installation

This library is mainly though to be used with symfony as it depends on its configuration files.

Syfmony

In your services.yaml (normally located at /config) Add this line:

imports:
    - { resource: ../vendor/monro/doctrine-nullable-embedabbles/src/EmbeNulls/config/services.yaml }

And if you need to change the doctrine.yaml location from the default one (%kernel.project_dir%/config/packages/doctrine.yaml), you can set the env variable DOCTRINE_CONFIG_FILEin your .env

Usage

Define your orm mappings as usual in your YML files and on the embedded property add nullable to true wherever you want. For instance:

#Dog.orm.yml
Some\Namespace\Dog:
    type: entity
    table: dog
    id: ...
    fields: 
        name:
            type: string
    
    embedded:
        petIdentificationNumber:
            class: Some\Namespace\PetIdentificationNumber
            nullable: true

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固