arakibi
arakibi

Reputation: 447

Call another Controllers method in the current Controller in Typo3

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

Answers (1)

rob-ot
rob-ot

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

Related Questions