Skip to content

Empty configuration for SoftDeleteableListener #314

@edrush

Description

@edrush

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions