There is an entity Partner (Partner)
class Partner { /** * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") * @ORM\Column(type="integer") */ protected $id; /** * @ORM\Column(type="string") */ protected $name; /** * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Service") * @ORM\JoinTable(name="partners_services", * joinColumns={@JoinColumn(name="partner_id", referencedColumnName="id")}, * inverseJoinColumns={@JoinColumn(name="service_id", referencedColumnName="id")} *) */ protected $services; }
There is an entity Service (Service)
class SubService { /** * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") * @ORM\Column(type="integer") */protected $id; /** * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Service", inversedBy="subServices") * @ORM\JoinColumn(name="service_id", referencedColumnName="id") */ protected $service; }
There is an entity subservice
class SubService { /** * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") * @ORM\Column(type="integer") */protected $id; /** * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Service", inversedBy="subServices") * @ORM\JoinColumn(name="service_id", referencedColumnName="id") */ protected $service; }
Each partner can have a set of services and services. You can add the subServices regiment to the Partner entity and make ManyToMany communications, but then it’s difficult to display the full Services tree and their sub-services.
How can I register a connection to receive objects like this
$partner->getServices()->getSubServices()