/
SummaryObjectCreatorTrait.php
45 lines (37 loc) · 1.6 KB
/
SummaryObjectCreatorTrait.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Concrete\Core\Board\Instance\Slot\Content;
use Concrete\Core\Summary\Category\CategoryMemberInterface;
use Concrete\Core\Summary\SummaryObject as BaseSummaryObject;
trait SummaryObjectCreatorTrait
{
public function createSummaryContentObjects(CategoryMemberInterface $mixed) : array
{
$objects = [];
if ($mixed->hasCustomSummaryTemplates()) {
$this->logger->debug(t('Has custom summary templates, checking custom array.'));
$templates = $mixed->getCustomSelectedSummaryTemplates();
} else {
$this->logger->debug(t('Does not have custom summary templates, checking base array.'));
$templates = $mixed->getSummaryTemplates();
}
$this->logger->debug(t('%s summary templates retrieved for object %s - %s',
count($templates),
$mixed->getSummaryCategoryHandle(),
$mixed->getSummaryIdentifier()
));
foreach($templates as $template) {
$objects[] = new SummaryObject(
new BaseSummaryObject(
$mixed->getSummaryCategoryHandle(),
$mixed->getSummaryIdentifier(),
$template->getTemplate(),
$template->getData()
)
);
$this->logger->debug(t('Creating summary content object for %s - %s with template %s and data %s',
$mixed->getSummaryCategoryHandle(), $mixed->getSummaryIdentifier(),
$template->getTemplate()->getName(), json_encode($template->getData())));
}
return $objects;
}
}