2017 © Pedro Peláez
 

symfony-bundle entity-change-watch-bundle

Allows you to listen to the life cycle of your entities

image

actiane/entity-change-watch-bundle

Allows you to listen to the life cycle of your entities

  • Monday, April 23, 2018
  • by puget.e
  • Repository
  • 4 Watchers
  • 5 Stars
  • 1,752 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 27 Versions
  • 54 % Grown

The README.md

EntityChangeWatchBundle

travis build Coverage Status Scrutinizer Code Quality, (*1)

This bundle allow to watch changes made on specific properties of entities using the doctrine2 life cycles events, (*2)

INSTALLATION

Create a yaml file inside the packages directory, (*3)

USAGE

Examples

entity_change_watch:
    classes:
        Entity\MyEntity:
            create:
                - {name: 'MyEntityService', method: 'doSomethingBeforeFlush', flush: false}
            delete:
                - {name: 'MyEntityService', method: 'doSomething'}
            update:
                all:
                    - {name: 'MyEntityService', method: 'doSomething'}
                properties:
                    property1:
                        - {name: 'MyEntityService', method: 'doSomething'}
                    property2:
                        - {name: 'MyEntityService', method: 'doSomethingElse'}
class MyEntityService
{
    public function doSomething(MyEntity $myEntity)
    {
        /*

        do something
        */
    }

    public function doSomethingBeforeFlush(MyEntity $myEntity)
    {
        /*

        do something before the flush
        */
    }

    public function doSomethingElse(MyEntity $myEntity, array $changedProperties, EntityManagerInterface $entityManager)
    {
        /*

        do something else
        */
    }

Callbacks services definition

All callback services must be tagged with actiane.entitychangewatch.callback, (*4)

Callbacks method

Please note that the orders of the arguments matter, (*5)

The first argument is the entity The second argument $changedProperties contains an array with all the changes applied to the entity. The third argument $$entityManager is the entityManager, (*6)

A callback is called after the flush, you can not execute another flush in this method., (*7)

If you whish to add or modify entities, you need to set the flush parameter to false, (*8)

 - {name: 'MyEntityService', method: 'doSomethingBeforeFlush', flush: false}

If you create and persist a new entity in this callback, then calling EntityManager#persist() is not enough. You have to execute an additional call to $unitOfWork->computeChangeSet($classMetadata, $entity)., (*9)

Changing primitive fields or associations requires you to explicitly trigger a re-computation of the changeset of the affected entity. This can be done by calling $unitOfWork->recomputeSingleEntityChangeSet($classMetadata, $entity)., (*10)

The Versions

20/04 2018
12/03 2018

v2.1.1

2.1.1.0

Allows you to listen to the life cycle of your entities

  Sources   Download

MIT

The Requires

 

12/03 2018

v2.1.0

2.1.0.0

Allows you to listen to the life cycle of your entities

  Sources   Download

MIT

The Requires

 

12/03 2018

v2.0.3

2.0.3.0

Allows you to listen to the life cycle of your entities

  Sources   Download

MIT

The Requires

 

06/03 2018

v1.1.x-dev

1.1.9999999.9999999-dev

Allows you to listen to the life cycle of your entities

  Sources   Download

MIT

The Requires

 

06/03 2018

v1.1.3

1.1.3.0

Allows you to listen to the life cycle of your entities

  Sources   Download

MIT

The Requires

 

08/12 2017

v1.1.2

1.1.2.0

Allows you to listen to the life cycle of your entities

  Sources   Download

MIT

The Requires

 

08/12 2017

v1.0.x-dev

1.0.9999999.9999999-dev

Allows you to listen to the life cycle of your entities

  Sources   Download

MIT

The Requires

 

08/12 2017

v1.0.2

1.0.2.0

Allows you to listen to the life cycle of your entities

  Sources   Download

MIT

The Requires

 

08/12 2017

v2.0.2

2.0.2.0

Allows you to listen to the life cycle of your entities

  Sources   Download

MIT

The Requires

 

05/12 2017

v2.0.0

2.0.0.0

Allows you to listen to the life cycle of your entities

  Sources   Download

MIT

The Requires

 

04/12 2017

v1.1.1

1.1.1.0

Allows you to listen to the life cycle of your entities

  Sources   Download

MIT

The Requires

 

30/11 2017

v1.1.0

1.1.0.0

Allows you to listen to the life cycle of your entities

  Sources   Download

MIT

The Requires

 

24/11 2017

v1.0.1

1.0.1.0

Allows you to listen to the life cycle of your entities

  Sources   Download

MIT

The Requires

 

24/11 2017

v1.0.0

1.0.0.0

Allows you to listen to the life cycle of your entities

  Sources   Download

MIT

The Requires