0 votes

Hello,

I have noticed that Skipper is not recognizing attributes from parent class in the class that extends it.

Parent class is not @ORM\Entity but has attributes with @ORM\Column, @ORM\ManyToOne and other attribute related annotations.

Doctrine is recognizing those attributes and all columns in tables are created.

For example i have this parent class:

 /**
     * Class AbstractPerson
     * @package AppBundle\Entity
     *
     * * @ORM\Table(
     *     indexes={@ORM\Index(name="PersonVatIdIdx", columns={"vatId"}),@ORM\Index(name="PersonNameIdx", columns={"name"})}
     * )
     */

abstract class AbstractPerson extends ServiceSubscribersEntity
{

    /**
     * @ORM\Column(type="string", length=256, nullable=false)
     * @Assert\NotBlank(message="Polje je obavezno")
     */
    protected $name;

...

And this class that extends it:

/**
 * @ORM\Entity
 *
 */
class Person extends AbstractPerson
{

    /**
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\RelatedPersonType")
     * @ORM\JoinTable(
     *     name="RelatedPersonTypeToPerson",
     *     joinColumns={@ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false)},
     *     inverseJoinColumns={@ORM\JoinColumn(name="related_person_type_id", referencedColumnName="id", nullable=false)}
     * )
     */
    protected $relatedPersonType;
...

The problem:

Skipper is not recognizing anything from parent class even though code is OK and Doctrine
creates everything defined in parent class, even indexes defined only in parent class.

Kind regards,
Darko

in Solved by (160 points)
recategorized by

1 Answer

0 votes

There is currently no support for such behavior / traits. We have a long-term plans to support it but unfortunately this will need a lot of new features, new code scanners and logic to implement it correctly.

Also such behavior is currently supported only for annotations but not for XML/YML, where we're trying to keep all features available for all available formats.

by Skipper developer (141k points)

Ludek,

thanks for the reply. I think I was not clear enough.

Skipper is not recognizing PHP attributes from parent classes.

In my example first class has attribute $name, second class extends it but Skipper only recognizes attributes from child class, in this case attribute $relatedPersonType. Attribute $name is missing in model but.

Kind regards,
Darko

As I wrote in my original post. Skipper currently doesn't support such inheritance.

If you want to import object to model, it's necessary to have both objects defined with @ORM\Entity tag.

Without that, it's not a inheritance in meaning of ORM, but only extending the classes via PHP which is not supported (as same as traits).

Skipper supports inheritnace defined via Doctrine2 mapping :

  • mapped superclass
  • single table inheritance
  • class table inheritance

Defined here:
http://doctrine-orm.readthedocs.org/en/latest/reference/inheritance-mapping.html

Thanks, I know that Skipper supports Doctrine2 inheritance mapping. It works great.
But that is not always appropriate solution in OOP.

I am evaluating Skipper on a real demo application that I am developing.

So I suggest to consider implementing support for inherited attributes.

For example FOSUserBundle is very popular in Symfony. And when used, base user class must be extended. But Skipper is not displaying all attributes that will be saved with user class:
enter image description here

And here are attributes that are actually present in that entity:
enter image description here

Thank you for example.

We're aware that there are situation when this feature will by handy. As I wrote, it's something we want to support but it will require a complex changes in codebase.

We have plans to support it but currently I don't have more specific ETA.

Any more information on the implementation of support for traits?

We postponed traits support. Because traits are very complex feature but with the very low Skipper users' interest.