0 votes

I am using ZF2 with skipper.

I have my main module entities, and I have a vendor "toolbox" with common elements that I use in all my apps.

I want to know how do I set up associations between my module entity and a vendor entity.

i.e.

in my module files I have Users
in my vedor entity I haev Countries

I want to create an association between Users and Countries

in Solved by (550 points)
recategorized by

1 Answer

0 votes

Hi,

I'm not sure I fully understand your question. You need to create common association between two entities? If so, simply use association tool, but this is something you probably know.

Or are you asking how to set-up ownership of association to stay in your app-module and not vendor module? If so, association always belongs to module where is also owner-entity. So if this is your question, you need to use only such type of associations.

by Skipper developer (135k points)

Hi - No this is not the question.

In zf2 I have the following folder structure:

/app/module/Application/Entity/SomeEntity.php
/app/module/User/UserEntity.php
/app/module/skipper.file
/app/vendor/toolbbox/module/Entity/CountriesEntity.php

The skipper gui builds associations in the module directory only:

UserEntity.php -> SomeEntity.php
UserEntity.php -> SomeOtherEntity.php

In the gui I do not have the vendor folder Entity listed... since it is a third party and I can not modify it.

I still however wish to create an association from my UserEntity.php -> CountriesEntity.php so that I have the correct annotations in the user entity:

/**
 * @ORM\ManyToOne(targetEntity="ToolBox\Entity\Countries", inversedBy="user", cascade={"persist"})
 * @ORM\JoinColumn(name="country_id", referencedColumnName="id")
 * @var Collection
 * @access private
 */
private $country;

I do not see anyway of doing this in Skipper... and when I add the annotations manually, they get erased.

Essentially I want to skipper to manage UserEntity and ignore Countries Entity.

Hopw that helps.

  • b

This is strange. There is no reason why should Skipper ignore your CountriesEntity.php file in vendor directory.

Are you importing whole /app directory? And does CountriesEntity have a correct @Entity annotation?

Try to import this file manually via "Import to project" -> "Import ORM Schema file".

enter image description here

If this also didn't help it's probably something wrong with the file.