Skip to content

Commit

Permalink
Check if artcle route exist for current tenant
Browse files Browse the repository at this point in the history
  • Loading branch information
zkabic committed Feb 8, 2024
1 parent abd8009 commit 1d29ffb
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use SWP\Bundle\ContentBundle\Model\ArticleInterface;
use SWP\Bundle\ContentBundle\Model\ArticlePreviousRelativeUrl;
use SWP\Bundle\ContentBundle\Model\RouteInterface;
use SWP\Bundle\CoreBundle\Tests\Controller\ArticleAutoPublishTest;
use SWP\Bundle\SettingsBundle\Manager\SettingsManagerInterface;
use SWP\Component\MultiTenancy\Context\TenantContextInterface;
use Symfony\Component\Routing\RouterInterface;
Expand Down Expand Up @@ -88,7 +89,17 @@ protected function duplicateUrl(ArticleInterface $article, string $route): bool
private function savePreviousRelativeUrl(ArticleInterface $article, RouteInterface $route = null): void
{
$route = $route ?? $article->getRoute();
$relativeUrlString = $this->router->generate($route->getName(), ['slug' => $article->getSlug()]);

try {
$relativeUrlString = $this->router->generate($route->getName(), ['slug' => $article->getSlug()]);
} catch (\Throwable $e) {
/**
* Route probably not exist for current tenant. Silently skipp.
* @see ArticleAutoPublishTest::testContentCorrectOnPublishedToManyTenantsPackakage()
*/
return;
}

if ($this->duplicateUrl($article, $relativeUrlString)) {
return;
}
Expand Down

0 comments on commit 1d29ffb

Please sign in to comment.