mirror of
https://github.com/Codappix/search_core.git
synced 2024-12-27 12:56:11 +01:00
[TASK] Add objectmanager via constructor DI injection
This commit is contained in:
parent
2c5ab1b57a
commit
2ee4a88a67
1 changed files with 10 additions and 9 deletions
|
@ -27,12 +27,18 @@ use Codappix\SearchCore\Domain\Index\TcaIndexer;
|
|||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Core\Utility\RootlineUtility;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
|
||||
|
||||
/**
|
||||
* Specific indexer for Pages, will basically add content of page.
|
||||
*/
|
||||
class PagesIndexer extends TcaIndexer
|
||||
{
|
||||
/**
|
||||
* @var ObjectManagerInterface
|
||||
*/
|
||||
protected $objectManager;
|
||||
|
||||
/**
|
||||
* @var TcaTableServiceInterface
|
||||
*/
|
||||
|
@ -44,20 +50,16 @@ class PagesIndexer extends TcaIndexer
|
|||
*/
|
||||
protected $fileRepository;
|
||||
|
||||
/**
|
||||
* @param TcaTableServiceInterface $tcaTableService
|
||||
* @param TcaTableServiceInterface $contentTableService
|
||||
* @param ConnectionInterface $connection
|
||||
* @param ConfigurationContainerInterface $configuration
|
||||
*/
|
||||
public function __construct(
|
||||
TcaTableServiceInterface $tcaTableService,
|
||||
TcaTableServiceInterface $contentTableService,
|
||||
ConnectionInterface $connection,
|
||||
ConfigurationContainerInterface $configuration
|
||||
ConfigurationContainerInterface $configuration,
|
||||
ObjectManagerInterface $objectManager
|
||||
) {
|
||||
parent::__construct($tcaTableService, $connection, $configuration);
|
||||
$this->contentTableService = $contentTableService;
|
||||
$this->objectManager = $objectManager;
|
||||
}
|
||||
|
||||
protected function prepareRecord(array &$record)
|
||||
|
@ -141,8 +143,7 @@ class PagesIndexer extends TcaIndexer
|
|||
protected function fetchAccess(int $uid, array $pageAccess): array
|
||||
{
|
||||
try {
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
$rootline = $objectManager->get(RootlineUtility::class, $uid)->get();
|
||||
$rootline = $this->objectManager->get(RootlineUtility::class, $uid)->get();
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->logger->notice(
|
||||
sprintf('Could not fetch rootline for page %u, because: %s', $uid, $e->getMessage()),
|
||||
|
|
Loading…
Reference in a new issue