extbase repository findAll() returns result null

折月煮酒 提交于 2019-11-30 18:54:50

This has bugged me for days (or weeks). The StoragePid (the reference to the page where your database items are attached to) does not make it to the database query if you don't define the following somewhere in your TypoScript:

plugin.tx_myextension.persistence.storagePid = 4

Put this in your Page-TS and the findAll method from Tx_Extbase_Persistence_Repository should be working fine.

Weeks.

Or you could force Repository to ignore Storage Page:

class MymodelRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
  public function initializeObject() {

  $this->defaultQuerySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings');
  $this->defaultQuerySettings->setRespectStoragePage(FALSE);
 }
}

From now on your Repository will pull every record from the database.

Are you sure that the return value of findAll() is NULL?

It could be that your Dependency Injection doesn't work. Then the Exception should be something like this:

findAll() is called on a Non-Object ($this->categoryRepository)

Also in your injectCategoryRepository you write $categoryRepository in lowerCamelCase and in the annotations in UpperCamelCase $CategoryRepository

Hope this helps..

As Hendrik said you can set it in your page-TS. Another solution is: in you BE, edit your page content that contains the plugin, select the Sys Folder, in which your db items are stored. This is found under the tab "Behaviour" for Typo3 v6.1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!