-
-
Save bwaidelich/9617211 to your computer and use it in GitHub Desktop.
{ | |
... | |
"require": { | |
"typo3/flow": "2.0.*", | |
"gedmo/doctrine-extensions": "2.3.*" | |
}, | |
... | |
} |
TYPO3: | |
Flow: | |
# disable reflection for non psr-0 compliant 3rd party packages | |
object: | |
excludeClasses: | |
'gedmo.doctrineextensions' : ['Gedmo\\.*'] | |
# register soft deletable filter & event listeners | |
persistence: | |
doctrine: | |
filters: | |
soft-deletable: 'Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter' | |
eventListeners: | |
- | |
events: ['onFlush', 'loadClassMetadata'] | |
listener: 'Gedmo\SoftDeleteable\SoftDeleteableListener' |
<?php | |
namespace Your\Package\Domain\Model; | |
use TYPO3\Flow\Annotations as Flow; | |
use Doctrine\ORM\Mapping as ORM; | |
use Gedmo\Mapping\Annotation as Gedmo; | |
/** | |
* Trait for soft-deletable entities. | |
* Usage: | |
* | |
* * Add @Gedmo\SoftDeleteable(fieldName="deletedAt") annotation to your entity | |
* * add "use SoftDeletableTrait;" to your entity | |
*/ | |
trait SoftDeletableTrait { | |
/** | |
* DateTime when this entity was deleted (used for "Soft-Delete behaviour") | |
* | |
* @var \DateTime | |
* @ORM\Column(nullable=true) | |
*/ | |
protected $deletedAt; | |
/** | |
* @return \DateTime | |
*/ | |
public function getDeletedAt() { | |
return $this->deletedAt; | |
} | |
/** | |
* @param \DateTime $deletedAt | |
* @return void | |
*/ | |
public function setDeletedAt(\DateTime $deletedAt) { | |
$this->deletedAt = $deletedAt; | |
} | |
} |
<?php | |
namespace Your\Package\Domain\Model; | |
use TYPO3\Flow\Annotations as Flow; | |
use Doctrine\ORM\Mapping as ORM; | |
use Gedmo\Mapping\Annotation as Gedmo; | |
/** | |
* Some Entity | |
* | |
* @Flow\Entity | |
* @Gedmo\SoftDeleteable(fieldName="deletedAt") | |
*/ | |
class SomeEntity { | |
use SoftDeletableTrait; | |
/** ..other properties ..*/ | |
} | |
?> |
Hi
I can't get rid of this exception when I try to get this working:
Uncaught Exception
[Semantical Error] The annotation "@Gedmo\Blameable" in property
Gedmo\Blameable\Traits\BlameableDocument::$createdBy was never
imported. Did you maybe forget to add a "use" statement for this annotation?
The setting TYPO3.Flow.object.excludeClasses
does not work?
Thanks
Found...
I had splitted the settings in two parts, and the first part was overriden by the second, so the excludeClass was not taken into account.
TYPO3:
Flow:
object:
excludeClasses:
'gedmo.doctrineextensions' : ['Gedmo\\.*']
TYPO3:
Flow:
persistence:
...
Worked like a charm! Thanks for sharing.
Unfortunately, my Flow version is yet outdate (shame on me), so I've done some extra patch on EntityManagerFactory (i.e.g: also added the buildEventManager).
Anyone knows how to mix softdeleteable
and blameable
in proper way? I want to update deleted_by
field when "removing" entity.
As I stumbled upon it:
Please notice the different spellings of "deleteable" and "deletable" (with/without additional "e") in the example. ;-)
Adding @Gedmo\SoftDeleteable(fieldName="deletedAt") annotation to your entity
to every entity is quite a hustle 😅
While using 'deletedAt' column name for soft deletion, one can use the SoftDeleteableEntity
which doesn't require annotations.
NOTE: This currently requires the GIT master of the TYPO3.Flow package (or specifically this patch https://review.typo3.org/27755)
Thanks to christianjul and mneuhaus for your help!