1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
BaseStep.php
См. документацию.
1<?php
2declare(strict_types=1);
3
4namespace Bitrix\Landing\Copilot\Generation\Step;
5
6use Bitrix\Landing\Copilot\Data;
7use Bitrix\Landing\Copilot\Generation;
8use Bitrix\Landing\Copilot\Generation\GenerationException;
9use Bitrix\Landing\Copilot\Generation\Type\GenerationErrors;
10
11abstract class BaseStep implements IStep
12{
15 protected ?int $stepId;
16
17 protected bool $initied = false;
18 protected bool $changed = false;
19
20 public function __construct()
21 {
22 }
23
27 public function init(Generation $generation, int $stepId): static
28 {
29 if ($this->initied)
30 {
31 return $this;
32 }
33
34 if (!Generation::checkExists($generation->getId()))
35 {
36 throw new GenerationException(
37 GenerationErrors::dataValidation,
38 "Generation {$generation->getId()} does not exist",
39 );
40 }
41
42 $this->generation = $generation;
43 $this->siteData = $generation->getSiteData();
44 $this->stepId = $stepId;
45 $this->initied = true;
46
47 $this->initialize();
48
49 return $this;
50 }
51
56 abstract protected function initialize(): void;
57
61 public function execute(): bool
62 {
63 if (!isset($this->generation, $this->siteData))
64 {
65 return false;
66 }
67
68 return true;
69 }
70
74 public function isAsync(): bool
75 {
76 return false;
77 }
78
82 public function isChanged(): bool
83 {
84 return $this->changed;
85 }
86
90 public function clearErrors(): void
91 {}
92
97 protected function getEvent(): Generation\Event
98 {
99 return $this->generation->getEvent();
100 }
101}
init(Generation $generation, int $stepId)
Определения BaseStep.php:27
Определения cookies.php:2
Определения buffer.php:3