can anyone provide a complete example of the Blameable Gedmo extension, and especially the configuration of the Blameable Listener ?
I am using the code provided by the documentation:
* @var User $createdBy
*
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="Cf\UserBundle\Entity\User")
* @ORM\JoinColumn(name="createdBy", referencedColumnName="id")
*/
private $createdBy;
/**
* @var User $updatedBy
*
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="Cf\UserBundle\Entity\User")
* @ORM\JoinColumn(name="updatedBy", referencedColumnName="id")
*/
private $updatedBy;
BUT the createdBy and updatedBy database columns are always NULL.
The documentation provides example to configure the other listeners (e.g. timestampable which I got working) but I find no example or documentation for the blameable listener.
Thanks for any help!!
===============================================================
EDIT to answer Jean:
yes I added the use which is:
use Gedmo\Mapping\Annotation as Gedmo;
I also use the Timestampable with the provided trait:
use Gedmo\Timestampable\Traits\TimestampableEntity;
// doctrine comments removed
class Document
{
use TimestampableEntity;
...
}
and the timestampable configuration is:
services:
gedmo.listener.timestampable:
class: Gedmo\Timestampable\TimestampableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
calls:
- [ setAnnotationReader, [ @annotation_reader ] ]
Timespambable works just fine.
I tried a similar configuration for the blameable listener since it has a setUserValue
method:
gedmo.listener.blameable:
class: Gedmo\Blameable\BlameableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
calls:
- [ setAnnotationReader, [ @annotation_reader ] ]
- [ setUserValue, [ @security.token_storage ] ]
but it doesn't work, I get this error (the 4 bundles are the ones used in my project):
The class 'Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage' was not found in the chain configured namespaces Cf\UserBundle\Entity, Cf\DocumentBundle\Entity, Cf\SouffleBundle\Entity, FOS\UserBundle\Model
I understand it is missing the user id or security token as an argument in one way or another but I just can't find an example anywhere. That's where I'm stuck. Any idea ?