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();