2017 © Pedro Peláez
 

symfony-bundle doctrine-auditable-bundle

Doctrine auditable bundle is alternative for DoctrineExtensions Loggable

image

gtt/doctrine-auditable-bundle

Doctrine auditable bundle is alternative for DoctrineExtensions Loggable

  • Wednesday, January 10, 2018
  • by gtt
  • Repository
  • 5 Watchers
  • 3 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Doctrine Auditable Bundle helps tracking changes and history of objects

Auditable behavioral implementation helps tracking changes and history of objects. Fast and lightweight alternative for DoctrineExtensions Loggable with some features. Supports only ORM., (*1)

Features

  • Group of changes
  • Comments for changes
  • Convenient store (tracked values before and after change stored in the separated columns, instead serialized entity data in the Loggable)
  • Supports custom DBAL types
  • Supports class inheritance configuration

Installation

  1. Install bundle
composer require "gtt/doctrine-auditable-bundle"
  1. Add to Kernel.php
public function registerBundles()
{
    $bundles = array(
        ...
        new Gtt\Bundle\DoctrineAuditableBundle\DoctrineAuditableBundle(),
    );
    ...
}
  1. Create tables for changes storing
bin/console doctrine:schema:update --force
  1. Configure mapping if needed.

Usage

Add attributes for tracking property, (*2)

<?php

use Gtt\Bundle\DoctrineAuditableBundle\Mapping\Annotation as Auditable;

/**
 * My entity
 */
 #[ORM\Entity]
 #[ORM\Table(name: 'entity')]
 #[Auditable\Entity]
class Entity
{
     #[ORM\Column(name: 'assigned_user', type: 'string', length: 255)]
     #[Auditable\Property]
    protected string $assignedUser;

    ...
}

Then somewhere in a service change an entity property and flush the changes., (*3)

<?php

use Doctrine\ORM\EntityManagerInterface;
use Gtt\Bundle\DoctrineAuditableBundle as Auditable;

class PayloadService {
    private Auditable\Log\Store $auditable;

    private EntityManagerInterface $entityManager;

    /**
     * Operate!
     */
    public function payloadMethod(YourDomain\Entity $entity): void 
    {
        // 1. change some property that supposed to be logged to changelog
        $entity->updateProperty();  // ... just dummy example

        // 2. describe this change
        $this->auditable->describe($entity, 'Change description');

        // 3. perform update 
        $this->entityManager->flush();
    }
}

The Versions

10/01 2018

dev-master

9999999-dev

Doctrine auditable bundle is alternative for DoctrineExtensions Loggable

  Sources   Download

MIT

The Requires

 

bundle doctrine symfony loggable auditable gtt

10/01 2018

1.0.2

1.0.2.0

Doctrine auditable bundle is alternative for DoctrineExtensions Loggable

  Sources   Download

MIT

The Requires

 

bundle doctrine symfony loggable auditable gtt

24/08 2017

1.0.1

1.0.1.0

Doctrine auditable bundle is alternative for DoctrineExtensions Loggable

  Sources   Download

MIT

The Requires

 

bundle doctrine symfony loggable auditable gtt

05/06 2017

1.0.0

1.0.0.0

Doctrine auditable bundle is alternative for DoctrineExtensions Loggable

  Sources   Download

MIT

The Requires

 

bundle doctrine symfony loggable auditable gtt