0 votes

We use the KnpDoctrineBehaviorsBundle and some other custom traits. Current import and export solution is not perfect. The program create class attributes (createdAt "column", updatedAt "column") in export. It is wrong.

Good and before export:

use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Model as ORMBehaviors;

// ...    
class Entity
{
    use ORMBehaviors\Timestampable\Timestampable,
        ORMBehaviors\Blameable\Blameable;

    /**
     * @ORM\Id
     * @ORM\Column(type="bigint", options={"unsigned" : true})
     * @ORM\GeneratedValue(strategy="AUTO")
     * @JMS\Groups({"lazy"})
     */
    protected $id;
}

After export:

use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Model as ORMBehaviors;

// ...    
class Entity
{
    use ORMBehaviors\Timestampable\Timestampable,
        ORMBehaviors\Blameable\Blameable;

    /**
     * @ORM\Id
     * @ORM\Column(type="bigint", options={"unsigned" : true})
     * @ORM\GeneratedValue(strategy="AUTO")
     * @JMS\Groups({"lazy"})
     */
    protected $id;
    // ...

    /** 
     * @ORM\Column(nullable=true)
     */
    private $updatedAt;

    /** 
     * @ORM\Column(nullable=true)
     */
    private $createdAt;
}
in Solved by
recategorized by

1 Answer

0 votes
Best answer

I'm not sure where is the problem.

ORM Designer currently doesn't support any Doctrine2 extensions or behaviors. So if your export contains updatedAt and createdAt fields it's because you add them to the model.

We have some long-term plans how to extend Doctrine2 import/export to support more types of annotations (like your @JMS, @Gedmo, ...) but right now ORM Designer can import/export only default Doctrine2 features.

by Skipper developer (136k points)
selected by

The ORM designer import the traits values. It is a good for us if the OD doesn't import them. Traits values after import: http://screencast.com/t/PEc34EzpGG and http://screencast.com/t/y1D2eskhzN

Can you please send me a complete file you're importing? Because If your import file looks like in your original example (without fields createdAt/updatedAt), this behavior isn't possible.

ORM Designer don't understand traits, so ORM Designer can't import these fields from anywhere else.

For anyone else who find a similar behavior of ORM Designer. The problem wasn't in traits, but inside the @Entity annotations.

There were these annotations:

 *      @ORM\Index(name="deletedAt_idx", columns={"deletedAt"}),
 *      @ORM\Index(name="createdAt_idx", columns={"createdAt"}),
 *      @ORM\Index(name="updatedAt_idx", columns={"updatedAt"}),
 *      @ORM\Index(name="uuid_idx", columns={"uuid"})

ORM Designer automatically creates all referred fields and entities, so in this case this means that ORM Designer automatically creates fields deletedAt, createdAt and updatedAt.