@@ -9,7 +9,7 @@ Features:
99- ORM and ODM support using same listener
1010- Can be nested with other behaviors
1111- Objects can be reverted to previous versions
12- - Annotation, Yaml and Xml mapping support for extensions
12+ - Attributes, Annotation, Yaml and Xml mapping support for extensions
1313
1414Update ** 2011-04-04**
1515
@@ -47,6 +47,12 @@ on how to setup and use the extensions in most optimized way.
4747will store logs to optionally specified ** logEntryClass** . You will still need to specify versioned fields with the following annotation.
4848- ** @Gedmo \Mapping\Annotation\Versioned** tracks annotated property for changes
4949
50+ ### Loggable annotations:
51+
52+ - ** \# [ Gedmo\Mapping\Annotation\Loggable(logEntryClass: MyClass::class] ** this class attribute
53+ will store logs to optionally specified ** logEntryClass** . You will still need to specify versioned fields with the following attribute.
54+ - ** \# [ Gedmo\Mapping\Annotation\Versioned] ** tracks attributed property for changes
55+
5056### Loggable username:
5157
5258In order to set the username, when adding the loggable listener you need to set it this way:
@@ -65,30 +71,41 @@ $evm->addEventSubscriber($loggableListener);
6571you need to identify entity as being Loggable. The metadata is loaded only once when
6672cache is active
6773
74+ ** Note:** this example is using annotations and attributes for mapping, you should use
75+ one of them, not both.
76+
6877``` php
6978<?php
7079namespace Entity;
7180
7281use Gedmo\Mapping\Annotation as Gedmo;
82+ use Doctrine\DBAL\Types\Types;
7383use Doctrine\ORM\Mapping as ORM;
7484
7585/**
7686 * @ORM\Entity
7787 * @Gedmo\Loggable
7888 */
89+ #[ORM\Entity]
90+ #[Gedmo\Loggable]
7991class Article
8092{
8193 /**
8294 * @ORM\Column(name="id", type="integer")
8395 * @ORM\Id
8496 * @ORM\GeneratedValue(strategy="IDENTITY")
8597 */
98+ #[ORM\Id]
99+ #[ORM\Column(name: 'id', type: Types::INTEGER)]
100+ #[ORM\GeneratedValue(strategy: 'IDENTITY')]
86101 private $id;
87102
88103 /**
89104 * @Gedmo\Versioned
90105 * @ORM\Column(name="title", type="string", length=8)
91106 */
107+ #[Gedmo\Versioned]
108+ #[ORM\Column(name: 'title', type: Types::STRING, length: 8)]
92109 private $title;
93110
94111 public function getId()
@@ -118,20 +135,26 @@ namespace Document;
118135
119136use Gedmo\Mapping\Annotation as Gedmo;
120137use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
138+ use Doctrine\ODM\MongoDB\Types\Type;
121139
122140/**
123141 * @ODM\Document(collection="articles")
124142 * @Gedmo\Loggable
125143 */
144+ #[Gedmo\Loggable]
145+ #[ODM\Document(collection: 'articles')]
126146class Article
127147{
128148 /** @ODM\Id */
149+ #[ODM\Id]
129150 private $id;
130151
131152 /**
132153 * @ODM\Field(type="string")
133154 * @Gedmo\Versioned
134155 */
156+ #[Gedmo\Versioned]
157+ #[ODM\Field(type: Type::STRING)]
135158 private $title;
136159
137160 public function __toString()
0 commit comments