Commit 9cf368cf by Van

add conditions back

parent 1173d518
...@@ -32,26 +32,28 @@ class CustomQueriesExtension extends SimpleExtension ...@@ -32,26 +32,28 @@ class CustomQueriesExtension extends SimpleExtension
$subject = $event->getSubject(); $subject = $event->getSubject();
/** @var \Bolt\Storage\Mapping\ContentType $contentType */ /** @var \Bolt\Storage\Mapping\ContentType $contentType */
$contentType = $subject->getContentType(); $contentType = $subject->getContentType();
$fields = $contentType->getFields(); if ($contentType){
$fields = $contentType->getFields();
$customQueryFields = [];
foreach ($fields as $key => $field) { $customQueryFields = [];
if($field['class'] === 'customQuery') { foreach ($fields as $key => $field) {
$customQueryFields[$key] = true; if($field['class'] === 'customQuery') {
break; $customQueryFields[$key] = true;
break;
}
} }
}
if(!empty($customQueryFields)) { if(!empty($customQueryFields)) {
foreach ($customQueryFields as $field => $customQueryField) { foreach ($customQueryFields as $field => $customQueryField) {
$fieldJson = $subject->get($field); $fieldJson = $subject->get($field);
if($fieldJson) { if($fieldJson) {
$jsonArray = \json_decode($fieldJson, true); $jsonArray = \json_decode($fieldJson, true);
$jsonArray['count'] = $this->countGroupedByContent($jsonArray, $fieldJson); $jsonArray['count'] = $this->countGroupedByContent($jsonArray, $fieldJson);
$newFieldJson = \json_encode($jsonArray); $newFieldJson = \json_encode($jsonArray);
$subject->set($field, $newFieldJson); $subject->set($field, $newFieldJson);
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment