steevanb/doctrine-events

Add Doctrine events

1.2.0 2017-02-15 15:55 UTC

This package is auto-updated.

Last update: 2024-09-28 12:39:33 UTC


README

version doctrine php Lines Total Downloads SensionLabsInsight Scrutinizer

doctrine-events

Add some events to Doctrine 2.5

Fix a Doctrine UnitOfwork bug with extraUpdates, who are not removed when you add and remove your entity before calling flush()

Changelog

onCreateEntityOverrideLocalValues

Dispatched when UnitOfWork try to know if current entity must be filled with values retrieved from query, or if this entity is already known and fields are already defined.

onCreateEntityDefineFieldValues

Dispactched when UnitOfWork define entity field values

onNewEntityInstance

Dispactched when UnitOfWork create new instance of your Entity

Installation

Add it to your composer.json :

{
    "require": {
        "steevanb/doctrine-events": "^1.2",
    }
}

You have to use steevanb\DoctrineEvents\Doctrine\ORM\EntityManager instead of Doctrine\ORM\EntityManager

Internally, it will use steevanb\DoctrineEvents\Doctrine\ORM\UnitOfWork instead of Doctrine\ORM\UnitOfWork

If you are on Symfony2 or Symfony3 project, you can add it to your config :

# app/config.yml
parameters:
    doctrine.orm.entity_manager.class: steevanb\DoctrineEvents\Doctrine\ORM\EntityManager

Some lib who use it

https://github.com/steevanb/doctrine-entity-merger : add MERGE_ENTITY hint to define fields loaded with multiple queries, with PARTIAL, instead of returning first hydrated entity