Skip to content

Commit

Permalink
Add deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
Prokyonn committed Dec 20, 2023
1 parent 9f84b43 commit 7950924
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
}
}

/**
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7950924

Please sign in to comment.