Skip to content

Commit

Permalink
add aggregated ratings to json linked data
Browse files Browse the repository at this point in the history
  • Loading branch information
m-vo committed Jul 20, 2019
1 parent 257e18b commit 2de5930
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/ContentElement/EventBookingElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
/*
* Regiondo Bundle for Contao Open Source CMS.
*
* @copyright Copyright (c) 2018, derhaeuptling
* @copyright Copyright (c) 2019, derhaeuptling
* @author Codefog <https://codefog.pl>
* @author Moritz V. <https://github.com/m-vo>
* @license MIT
*/

Expand Down Expand Up @@ -148,6 +149,15 @@ protected function generateJsonLinkedData(CalendarEventsModel $model): array
],
];

// Add aggregate ratings if present
if ($originalData['reviews_count'] && $originalData['rating_summary']) {
$data['aggregateRating'] = [
'@type' => 'AggregateRating',
'ratingCount' => $originalData['reviews_count'],
'ratingValue' => $originalData['rating_summary'],
];
}

// Add the image
if ($model->addImage && null !== ($image = FilesModel::findByPk($model->singleSRC)) && \is_file(TL_ROOT.'/'.$image->path)) {
$data['image'] = Environment::get('url').'/'.$image->path;
Expand Down

0 comments on commit 2de5930

Please sign in to comment.