Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loggable with softdeleteable and uploadable #256

Open
gzbucki opened this issue Sep 8, 2014 · 1 comment
Open

Loggable with softdeleteable and uploadable #256

gzbucki opened this issue Sep 8, 2014 · 1 comment

Comments

@gzbucki
Copy link

gzbucki commented Sep 8, 2014

Hi,

I'm trying to use this three extensions together, but i have some issues.
First of all, i tried updating report entity which params: path and size are versioned, but no changes are logged.
After creating new entity, there is create action logged, but path and size params are logged as nulls.

I tried messing around with listener priorities.
I changed uploadable priority which fixed the update action versioning, but screwed up soft delete logging (remove).
Tried to change softdeleteable priority, but it doesn't change anything apart from totally screwing up softdelete (the file is being deleted)

Just can't get these three to work with each other

@mohamedaymenkarmous
Copy link

Hi,
Did you try switching priorities ?
I have not already tested Softdeleteable with Loggable and Uploadable.
But I tested Loggable and Uploadable together.
I'm using SYmfony 4.1. And in this release I got this results:

For Uploadable:


# php bin/console debug:container stof_doctrine_extensions.listener.uploadable

Information for Service "stof_doctrine_extensions.listener.uploadable"
======================================================================

 ---------------- ---------------------------------------------------------------
  Option           Value
 ---------------- ---------------------------------------------------------------
  Service ID       stof_doctrine_extensions.listener.uploadable
  Class            Gedmo\Uploadable\UploadableListener
  Tags             doctrine.event_subscriber (connection: default, priority: -5)
  Calls            setAnnotationReader, setDefaultFileInfoClass
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        no
  Autoconfigured   no
 ---------------- ---------------------------------------------------------------

And for Loggable:

# php bin/console debug:container stof_doctrine_extensions.listener.loggable

Information for Service "stof_doctrine_extensions.listener.loggable"
====================================================================

 ---------------- --------------------------------------------------------------
  Option           Value
 ---------------- --------------------------------------------------------------
  Service ID       stof_doctrine_extensions.listener.loggable
  Class            Gedmo\Loggable\LoggableListener
  Tags             doctrine.event_subscriber (connection: default, priority: 5)
  Calls            setAnnotationReader
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        no
  Autoconfigured   no
 ---------------- --------------------------------------------------------------

After seeing this, I was surprised why Loggable have a higher priority than Uploadable (5 >> -5).

So I was forced to switch priorities.

I'm not sure about choosing the right priorities but I think that It's prefereable for me to keep priorities under the default (default=0) because most listeners have a default priorities even the kernel.controller event-dispatcher. Just keep a look at this command to understand:

php bin/console debug:event-dispatcher

So I just set the Uploadable priority to -5 and the Loggable priority to -7 (it's a choice). And after uploading a file, I found the file info in the "ext_log_entries" table.

To do set these priorities, I overrited the listeners in the config/services.yaml (for Symfony 4).
And I set:

services:
    stof_doctrine_extensions.listener.uploadable:
        class: Gedmo\Uploadable\UploadableListener
        tags:
            - { name: doctrine.event_subscriber, priority: -5 }
    stof_doctrine_extensions.listener.loggable:
        class: Gedmo\Loggable\LoggableListener
        tags:
            - { name: doctrine.event_subscriber, priority: -7 }

I hope this can help anyone that found this problem like me.

And please if I said wrong concepts or any thing that should be corrected, don't hesitate to keep me informed.

Best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants