typo3typoscriptfluid

TYPO3: repository->findAll() not working


I am building an extension with a backend module. When I call the findAll() method it returns a "QueryResult" object.

I tried to retrieve objects with findByUid() and it does work.

I set the storage pid in the typoscript:

plugin.tx_hwforms.persistence.storagePid = 112

I can also see it in the typoscript object browser.

I also added this to my repository class:

public function initializeObject()
    {
        $defaultQuerySettings = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class);
        $defaultQuerySettings->setRespectStoragePage(false);
        $this->setDefaultQuerySettings($defaultQuerySettings);
    }

so that the storage pid is ignored ... It's still not working, findAll doesn't return an array of entites as it should


Solution

  • Repository must return a QueryResult from the findAll methods. Only methods which return a single object (findOneByXYZ) will return anything else.

    All of the following operations will cause a QueryResult to load the actual results it contains. Until you perform one of these, no results are loaded and debugging the QueryResult will yield no information except for the original Query.

    Note that ->getFirst() and ->count() do not cause the original query to fire and will not fill results if they are not already filled. Instead, they will perform an optimised query.

    Summa summarum: when you get a QueryResult you must trigger it somehow, which normally happens when you begin to render the result set. It is not a prefilled array; it is a dynamically filled Iterator.