Browse Source

include the audit bundle and make parameters auditable

Olivier Massot 8 months ago
parent
commit
7b3069c43e

+ 1 - 0
composer.json

@@ -19,6 +19,7 @@
     "beberlei/doctrineextensions": "^1.3",
     "blackfire/php-sdk": "^1.23",
     "composer/package-versions-deprecated": "^1.11",
+    "damienharper/auditor-bundle": "^5.2",
     "doctrine/dbal": "^2.6",
     "doctrine/doctrine-bundle": "^2.1",
     "doctrine/doctrine-migrations-bundle": "^3.0",

+ 1 - 0
config/bundles.php

@@ -25,4 +25,5 @@ return [
     Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'docker' => true, 'test' => false, 'staging' => true],
     Hautelook\AliceBundle\HautelookAliceBundle::class => ['dev' => true, 'docker' => true, 'test' => false, 'staging' => true],
     Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true],
+    DH\AuditorBundle\DHAuditorBundle::class => ['all' => true],
 ];

+ 6 - 3
config/packages/dh_auditor.yaml.ori → config/packages/dh_auditor.yaml

@@ -1,12 +1,15 @@
 # Full configuration reference available at:
 # https://damienharper.github.io/auditor-docs/docs/auditor-bundle/configuration/reference.html
-# todo : mettre en place le script de nettoyage automatique des audits (le chiffre est le nombre de mois) : bin/console audit:clean 12 --no-confirm
 dh_auditor:
-    timezone: 'Europe/Paris'
     enabled: true
+    timezone: 'Europe/Paris'
     providers:
         doctrine:
-            table_prefix: null
+            table_prefix: ''
             table_suffix: '_audit'
+            entities:
+                App\Entity\Organization\Parameters: ~
+            auditing_services:
+                - '@doctrine.orm.default_entity_manager'
             storage_services:
                 - '@doctrine.orm.audit_entity_manager'

+ 2 - 2
config/secrets/docker/docker.DATABASE_AUDIT_URL.f1a8d2.php

@@ -1,3 +1,3 @@
-<?php // docker.DATABASE_AUDIT_URL.f1a8d2 on Thu, 16 Nov 2023 10:21:36 +0000
+<?php // docker.DATABASE_AUDIT_URL.f1a8d2 on Thu, 17 Apr 2025 15:29:02 +0000
 
-return "\x92\x26\xEA\x07\xB9\xE90\x27\xCCX\x94W\x05\x5D\x1E\xDF\x27\xAFG\xD0\xADx\xF1\x96\x81\x01\xDFE\xAF\xA6\xF4s\x83\x9DL\x02\xFE\x06r\xE5\x5C\xF4\xB4\xBBc\x88\xA1n9\x19\xA5\xD52o\xAE\xAF\xA5Vk\x3Dc\x1Ds\x9E\xFC\xD0\xF2\xAAca\xBD\x93\xC7\x01\xAC\x91N\xD3\xED\xE0\xE1qh\x28\xCD\x83\x3F\x7F\x9A\x9D\xDF\xB8\xCCn\xD7\xE3\x9Ax\x0C\xC9\x27";
+return "\x05\x60\x5E-\xCD\xA3l\x95\xBB\x28_H\xEC\xD7h\x13\x81\xAC\xE2\x25\xEE\x20\xC2\xCB\xD2\x5B6\x87\xA7\x94\xC11\xDD\xE3\xB1G\x94\x3Adtm\x9E\x85\x8E\xBBp\xE2\x1A\xF8\xA7r\xD5\x84\xB0Jd9\xC4\xE6C\xE5k\x05\xF2\xE8\xE2\x8F\x12\xA9o\x1F\xB3\x04\xE1\x97\xFE\xC6\x5BD\x09N\x1B\xD0\xDD\x94\x2A\xD1lzb\x8F\xA9qzT\xBE\xE4\xA4\x97\xB0x\xE8M\x9A\xF6G\x14\x3A\xF55\xFD\x25";

+ 16 - 0
doc/audit.md

@@ -0,0 +1,16 @@
+# Tables Audit
+
+Les tables audit sont alimentées par le bundle [auditor-bundle](https://damienharper.github.io/auditor-docs/docs/auditor-bundle/configuration/storage.html).
+
+Ces tables sont stockées dans une DB nommée "opentalent_audit", accessible via l'entity manager
+`@doctrine.orm.audit_entity_manager`.
+
+Pour créer la DB : 
+
+    php bin/console doctrine:database:create --connection=audit
+
+Pour mettre à jour le schéma de la DB : 
+
+    php bin/console audit:schema:update --force
+
+

+ 2 - 2
src/Entity/Organization/Parameters.php

@@ -18,8 +18,8 @@ use App\Enum\Organization\BulletinPeriodEnum;
 use App\Enum\Organization\SendToBulletinEnum;
 use App\Repository\Organization\ParametersRepository;
 use App\State\Processor\Organization\ParametersProcessor;
-// use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
 use App\Validator\Organization\Parameters as OpentalentAssert;
+use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
 use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\Common\Collections\Collection;
 use Doctrine\ORM\Mapping as ORM;
@@ -37,7 +37,7 @@ use Symfony\Component\Validator\Constraints as Assert;
     ],
     processor: ParametersProcessor::class
 )]
-// #[Auditable]
+#[Auditable]
 #[ORM\Entity(repositoryClass: ParametersRepository::class)]
 #[OpentalentAssert\MobytCredentials]
 class Parameters