/
ImportGatheringItemTemplatesRoutine.php
59 lines (55 loc) · 2.11 KB
/
ImportGatheringItemTemplatesRoutine.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Concrete\Core\Backup\ContentImporter\Importer\Routine;
use Concrete\Core\Block\BlockType\BlockType;
use Concrete\Core\Feature\Feature;
use Concrete\Core\Gathering\Item\Template\Template;
use Concrete\Core\Gathering\Item\Template\Type;
use Concrete\Core\Permission\Category;
use Concrete\Core\Validation\BannedWord\BannedWord;
class ImportGatheringItemTemplatesRoutine extends AbstractRoutine
{
public function getHandle()
{
return 'gathering_item_templates';
}
public function import(\SimpleXMLElement $sx)
{
if (isset($sx->gatheringitemtemplates)) {
foreach ($sx->gatheringitemtemplates->gatheringitemtemplate as $at) {
$pkg = static::getPackageObject($at['package']);
$type = Type::getByHandle((string) $at['type']);
$gatHasCustomClass = false;
$gatForceDefault = false;
$gatFixedSlotWidth = 0;
$gatFixedSlotHeight = 0;
if ($at['has-custom-class']) {
$gatHasCustomClass = true;
}
if ($at['force-default']) {
$gatForceDefault = true;
}
if ($at['fixed-slot-width']) {
$gatFixedSlotWidth = (string) $at['fixed-slot-width'];
}
if ($at['fixed-slot-height']) {
$gatFixedSlotHeight = (string) $at['fixed-slot-height'];
}
$template = Template::add(
$type,
(string) $at['handle'],
(string) $at['name'],
$gatFixedSlotWidth,
$gatFixedSlotHeight,
$gatHasCustomClass,
$gatForceDefault,
$pkg
);
foreach ($at->children() as $fe) {
$feo = Feature::getByHandle((string) $fe['handle']);
if (is_object($feo)) {
$template->addGatheringItemTemplateFeature($feo);
}
}
}
} }
}