Issue Bug Closed

#99949Repository initializeObject is never called

Miladin Bojic 02/14/23, 14:06 updated 06/24/23, 12:20

Description

I have this code in my repository class

<?php

namespace Vendor\ExtensionName\Domain\Repository;

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;

/**
 * Class ProductRepository
 */
class ProductRepository extends Repository
{
    public function initializeObject()
    {
        $querySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class);
        $querySettings->setLanguageOverlayMode(false);
        $querySettings->setRespectStoragePage(false);
        $this->setDefaultQuerySettings($querySettings);
    }
...

in the controller I have

/**
     * Inject the product repository
     *
     * @param ProductRepository $productRepository
     */
    public function injectProductRepository(ProductRepository $productRepository)
    {
        $this->productRepository = $productRepository;
    }

I also could notice, that this works if Dependency Injection is defined in Services.yml. But, I think, this should work also without using Services.yml

So, I would say – this is a bug or the docu https://docs.typo3.org/m/typo3/reference-coreapi/11.5/en-us/ExtensionArchitecture/Extbase/Reference/Domain/Repository.html is not acurate.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.