Skip to content

Commit

Permalink
Fix when content doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
lopes-vincent committed Dec 9, 2021
1 parent c0ffd70 commit d9dbfee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Loop/BetterSeoLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BetterSeoLoop extends BaseI18nLoop implements PropelSearchLoopInterface
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntTypeArgument('object_id'),
Argument::createAlphaNumStringTypeArgument('object_id'),
Argument::createAlphaNumStringTypeArgument('object_type'),
Argument::createIntTypeArgument('lang_id')
);
Expand Down
11 changes: 8 additions & 3 deletions Smarty/Plugins/BetterSeoMicroDataPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ public function betterSeoMicroData($params)
case 'content':
$id = $params['id'] ?? $this->request->get('content_id');
if ($id) {
$content = ContentQuery::create()->filterById($id)->findOne();
$microdata = $this->getContentMicroData($content, $lang);
$microdata = $this->getContentMicroData($id, $lang);
}
break;
}
Expand Down Expand Up @@ -283,8 +282,14 @@ protected function getFolderMicroData(Folder $folder, Lang $lang)
/**
* @return array
*/
protected function getContentMicroData(Content $content, Lang $lang)
protected function getContentMicroData($contentId, Lang $lang)
{
$content = ContentQuery::create()->filterById($contentId)->findOne();

if (null === $content) {
return null;
}

$content->setLocale($lang->getLocale());

$microData = [
Expand Down

0 comments on commit d9dbfee

Please sign in to comment.