From 7950924b0db0f38fe6300f53b0d8d33710216bb4 Mon Sep 17 00:00:00 2001 From: Prokyonn Date: Wed, 20 Dec 2023 15:10:13 +0100 Subject: [PATCH] Add deprecation --- Controller/ArticleController.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Controller/ArticleController.php b/Controller/ArticleController.php index a8fbc806..806edcbc 100644 --- a/Controller/ArticleController.php +++ b/Controller/ArticleController.php @@ -146,6 +146,10 @@ public function __construct( $this->securityChecker = $securityChecker; $this->displayTabAll = $displayTabAll; $this->documentInspector = $documentInspector; + + if (null === $this->documentInspector) { + @trigger_deprecation('sulu/article-bundle', '2.5', 'Instantiating the ArticleController without the $documentInspector argument is deprecated!'); + } } /** @@ -422,22 +426,25 @@ private function getRangeQuery(string $field, string $from, string $to): RangeQu public function getAction(Request $request, string $id): Response { $locale = $this->getRequestParameter($request, 'locale', true); + /** @var ArticleDocument $document */ $document = $this->documentManager->find( $id, $locale ); - $localizationState = $this->documentInspector->getLocalizationState($document); - - if ($localizationState === LocalizationState::GHOST) { - $document = $this->documentManager->find( - $id, - $locale, - [ - 'load_ghost_content' => false, - 'structure_type' => $document->getStructureType(), - ] - ); + if ($this->documentInspector) { + $localizationState = $this->documentInspector->getLocalizationState($document); + + if (LocalizationState::GHOST === $localizationState) { + $document = $this->documentManager->find( + $id, + $locale, + [ + 'load_ghost_content' => false, + 'structure_type' => $document->getStructureType(), + ] + ); + } } $context = new Context();