César Dueñas
César Dueñas

Reputation: 331

The findAll() of TYPO3 extbase repository in Command Controller returns empty object

I wanna use the repository in the Command Controller to execute a procedure from time to time. I have the repository inject in the Action Controller and Command Controller, there are exist objects but in the Command Controller returns empty.

I am using the next code in two places, Action and Command.

/**
 * postRepository
 *
 * @var \VENDOR\MyExt\Domain\Repository\PostRepository
 * @inject
 */
protected $postRepository = null;

....
....
$posts = $this->postRepository->findAll();
\TYPO3\CMS\Core\Utility\DebugUtility::debug($posts, 'posts');

And the moment of Debug. In Action Controller I get

TYPO3\CMS\Extbase\Persistence\Generic\QueryResultprototypeobject (5 items)

And in Command Controller

TYPO3\CMS\Extbase\Persistence\Generic\QueryResultprototypeobject (empty)

What is the correct way for use repositories in Command Controller or how could I get the objects in this?

I am using TYPO3 7.6, PHP 5.6 and APC cache in Install Tools and configure it in the Server, Centos 6

Upvotes: 1

Views: 2360

Answers (1)

Bill.Dagou
Bill.Dagou

Reputation: 260

I think the problem is the StoragePage is not set in your Command Controller. You may try $query->getQuerySettings()->setRespectStoragePage(FALSE) in your PostRepository, or module.tx_myext.persistence.storagePid = {$storagePid} in your extension TS.

Upvotes: 1

Related Questions