Reputation: 447
I have created an extension using Jbuilder , the purpose of this extension is to list out all countries and the addresses that belong to each country , so in the Jbuilder frontend I created 2 Models , Country and Address and I designed a (1--*) relation .
I could list the countries in a page , but I don't know how to list the Adresses in the same page , I don't know how to call Address's methods inside the listAction of the Country Controller ..
public function listAction() {
$lands = $this->landRepository->findAll();
$this->view->assign('lands', $lands);
}
Could somebody help me please .. I am new to typo3 and extensions .
Upvotes: 2
Views: 1466
Reputation: 1264
Inject your address repo in your controller:
/**
* addressRepository
*
* @var \Vendor\Extkey\Domain\Repository\addressRepository
* @inject
*/
protected $addressRepository;
and use it
public function listAction() {
$this->view->assign('lands', $this->landRepository->findAll() );
$this->view->assign('addressses', $this->addressRepository->findAll()) ;
}
Upvotes: 3