villermen/doctrine-identity-queuer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

villermen/doctrine-identity-queuer

Composer 安装命令:

composer require villermen/doctrine-identity-queuer

包简介

README 文档

README

Queue IDs for your next inserted entities.

Test

Description

This package adds an IdentityQueuer class, that allows you to set identities (IDs) of Doctrine entities in advance. It is able to do this for entities that are configured to have a different identity generation strategy.

This package's main use-case is to explicitly set IDs of entities that are created somewhere in your services during unit tests. It is not advised to use this package in production, as there are better ways of achieving custom ID generation outside of testing.

Usage

use Villermen\DoctrineIdentityQueuer\IdentityQueuer;

$identityQueuer = new IdentityQueuer($entityManager);
$identityQueuer->queueIdentity(User::class, 1234);

$user = new User()

$entityManager->persist($user);
$entityManager->flush();

// $user should have been given an id of 1234 instead of an automatically generated one!

Installing

composer require --dev villermen/doctrine-identity-queuer

How does it work?

IdentityQueuer will override the ID generator for entities when there are queued identities waiting for them. It subscribes to Doctrine's preFlush event to flush the entities with queued identies first, before performing the actual flush. Before performing the actual flush, the generators are changed back so that additional entities will behave like they originally would.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-03-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固