Implement Repository for foreign model


(Frank Mittendorf) #1

Hi developers!

Maybe its the wrong way, but …

I want to use Neos\Party\Domain\Model\ElectronicAddress in my project as a collection for a user. In this case one address could be “used” by several users (i.e. “info@domain.tdl”).
Now I need an implementation for a repository ElectronicAddressRepository.
Of course a “findAll()” fails: Call to a member function findAll() on null.

Is it possible to access the according database table (neos_party_domain_model_electronicaddress) without a custom SQL and use “normal” magic calls?

Any hints for me? Thanks!


(Alexander Berl) #2

Hello Frank,

There should actually be no problem with creating a ElectronicAddressRepository extending Neos\Flow\Persistence\Repository, since ElectronicAddress is a normal Flow Entity, BUT:

I’m a bit in doubt you actually want to directly query the electronic addresses as an own Aggregate, so maybe you can just explain a bit more what you actually want to achieve.
From what you wrote in your first two sentences, this would simply be solved by creating a ManyToMany relation between your User and ElectronicAddress.

Best regards,
Alexander


(Frank Mittendorf) #3

Hello Alexander!

Thanks for your answer!
I’ve got it by using ENTITY_CLASSNAME:

 class ElectronicAddressRepository extends Repository
{
    const ENTITY_CLASSNAME = \Neos\Party\Domain\Model\ElectronicAddress::class;
}

First I’ve left out the leading backslash - that does not work (of course).

Thanks again
Frank