CmsTemplateWriterStep   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 9
c 0
b 0
f 0
dl 0
loc 26
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 9 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