0 votes

Hi,

I'm using dynamic relations with "implements" and "traits".

How can I import this relations into Skipper?

    public function getSubscribedEvents()
{
    return [
        'loadClassMetadata',
    ];
}

/**
 * @param LoadClassMetadataEventArgs $eventArgs
 */
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
{
    /** @var ClassMetadata $metadata */
    $metadata = $eventArgs->getClassMetadata();
    $reflectionClass = new \ReflectionClass($metadata->getName());
    $implements = class_implements($metadata->getName());

    if (in_array('AppBundle\Entity\Interfaces\ShareInterface', $implements)) {
        /** @noinspection PhpUndefinedMethodInspection */
        $metadata->mapManyToMany([
            'targetEntity' => Share::CLASS,
            'cascade' => ['persist','remove'],
            'fieldName' => 'shares',
        ]);
    }
asked Jul 23 in Feature Request by MarcoDL (120 points)
recategorized Jul 25 by ludek.vodicka

1 Answer

0 votes

Hi,
unfortunately, traits aren't supported for now. It's because there is very low interest in this feature and on the other side complexity of such feature is very high.

answered Jul 25 by ludek.vodicka Skipper developer (125,850 points)

Hello Ludek,

We have recently discovered the power of traits and are starting using it.
Currently, we make a region in a bundle for traits and simply create normal entities.
We manually replace "class" by "trait" and add the "use" in the required entities by hand.
It all works fine, except, "trait" is always replaced by "class" on export to ORM.

Our basic need would be to be able to tag an entity as trait, so the the class becomes / stays "trait", this could be a simple attribute on the entity which puts trait instead of class during export.

More extensive support would be to actually use the traits in other entities, but this could come later.

Doctrine2, Symfony3, PHP 5.6+

Best regards

Michael

Hi Michael,

I believe that such simple tag would be possible I will discuss it with my colleagues and let you know.