Skip to content

Commit

Permalink
Change initialization of DocumentRepository in DocumentTypeFunctionPr…
Browse files Browse the repository at this point in the history
…ovider
  • Loading branch information
beatrycze-volk committed May 5, 2023
1 parent 09156ea commit f6f17a5
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;

/**
* Provider class for additional "getDocumentType" function to the ExpressionLanguage.
Expand Down Expand Up @@ -61,6 +61,14 @@ public function getFunctions()
*/
protected $documentRepository;

/**
* @param DocumentRepository $documentRepository
*/
public function injectDocumentRepository(DocumentRepository $documentRepository)
{
$this->documentRepository = $documentRepository;
}

/**
* Initialize the extbase repositories
*
Expand All @@ -72,15 +80,13 @@ protected function initializeRepositories($storagePid)
{
Helper::polyfillExtbaseClassesForTYPO3v9();

// TODO: When we drop support for TYPO3v9, we needn't/shouldn't use ObjectManager anymore
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$configurationManager = $objectManager->get(ConfigurationManager::class);
$frameworkConfiguration = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$frameworkConfiguration = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);

$frameworkConfiguration['persistence']['storagePid'] = MathUtility::forceIntegerInRange((int) $storagePid, 0);
$configurationManager->setConfiguration($frameworkConfiguration);

$this->documentRepository = $objectManager->get(DocumentRepository::class);
$this->documentRepository = GeneralUtility::makeInstance(DocumentRepository::class);
}

/**
Expand Down

0 comments on commit f6f17a5

Please sign in to comment.