CmsTemplateWriterStep::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 9
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of the Spryker Commerce OS.
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
declare(strict_types = 1);
9
10
namespace Pyz\Zed\DataImport\Business\Model\CmsTemplate;
11
12
use Orm\Zed\Cms\Persistence\SpyCmsTemplateQuery;
13
use Spryker\Zed\DataImport\Business\Model\DataImportStep\DataImportStepInterface;
14
use Spryker\Zed\DataImport\Business\Model\DataSet\DataSetInterface;
15
16
class CmsTemplateWriterStep implements DataImportStepInterface
17
{
18
    /**
19
     * @var string
20
     */
21
    public const KEY_TEMPLATE_NAME = 'template_name';
22
23
    /**
24
     * @var string
25
     */
26
    public const KEY_TEMPLATE_PATH = 'template_path';
27
28
    /**
29
     * @param \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetInterface $dataSet
30
     *
31
     * @return void
32
     */
33
    public function execute(DataSetInterface $dataSet): void
34
    {
35
        $cmsTemplate = SpyCmsTemplateQuery::create()
36
            ->filterByTemplateName($dataSet[static::KEY_TEMPLATE_NAME])
37
            ->findOneOrCreate();
38
39
        $cmsTemplate
40
            ->setTemplatePath($dataSet[static::KEY_TEMPLATE_PATH])
41
            ->save();
42
    }
43
}
44