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

Empty configuration for SoftDeleteableListener #314

Open
edrush opened this issue Feb 11, 2016 · 0 comments
Open

Empty configuration for SoftDeleteableListener #314

edrush opened this issue Feb 11, 2016 · 0 comments

Comments

@edrush
Copy link

edrush commented Feb 11, 2016

I have an abstract class that uses the SoftDeletable trait. I followed the documentation but SoftDeleteableFilter did not apply because the configuration array of SoftDeleteableListener was empty (here).

To solve that I added the annotation to my abstract class, which didn't help (plus I found about that here and not really in the documentation, but got amazed because of the annotation reader in combination with my trait, not sure there at all though).

My actual and unsatisfying solution is to annotate each of my concrete entities plus adding the $deletedAt property (which is already there through the trait).

I am confused. I would have expected that behaviour from the trait alone. Maybe plus the annotation in my abstract class.

Maybe it is related to the fact that I do no auto-mapping (entities in separate folder)? Or ist that a DoctrineExtensions question?

Do you want me to supply some code? It's straight your documentation (I think):

# config.yml
stof_doctrine_extensions:
  default_locale: %locale%
  orm:
    default:
      softdeleteable: true

doctrine:
  orm:
    entity_managers:
        default:
            connection: default
            mappings:
             XYZAdminBundle:
                type: annotation
                prefix: XYZ\ABC\Entity
                dir: %kernel.root_dir%/../src/XYZ/ABC/Entity
            filters:
              softdeleteable:
                class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
                enabled: true

My abstract class (which did still not work):

<?php
...
use Gedmo\Mapping\Annotation as Gedmo;

/**
* @Gedmo\SoftDeleteable(fieldName="deletedAt")
*/
abstract class MainEntity extends AbstractEntity
{
    use ORMBehaviors\SoftDeletable\SoftDeletable;
}

"Solution":

<?php
...
 /**
 * @Gedmo\SoftDeleteable(fieldName="deletedAt")
 */
class Thing extends MainEntity
{
  /**
   * @var \DateTime $deletedAt
   *
   * @ORM\Column(name="deletedAt", type="datetime", nullable=true)
   *  /
    protected $deletedAt;
  }

What am I missing? Thank you a lot.

Sorry for so much text. Is that rather a question for stackoverflow than an issue?

Edit: if I put the $deletedAt in my abstract class I get a Runtime notice ("define the same property..."), which seems understandable, but surprisingly it does not happen in the "Solution".

PHP 5.5.11, stof/doctrine-extensions-bundle: v1.2.2, gedmo/doctrine-extensions: v2.4.12

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

1 participant