1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
RequestMultiple.php
См. документацию.
1<?php
2declare(strict_types=1);
3
4namespace Bitrix\Landing\Copilot\Generation\Step;
5
6use Bitrix\Landing\Copilot\Connector\AI\Prompt;
7use Bitrix\Landing\Copilot\Generation;
8use Bitrix\Landing\Copilot\Generation\Request;
9use Bitrix\Landing\Copilot\Generation\Type\RequestEntityDto;
10
11abstract class RequestMultiple extends AIStep
12{
13 public function __construct()
14 {
15 parent::__construct();
16 }
17
21 protected array $entities = [];
22
26 protected array $requests = [];
27
28 abstract public static function getConnectorClass(): string;
29
33 protected function initialize(): void
34 {
35 $this->requests = Request::getByGeneration($this->generation->getId(), $this->stepId);
36 }
37
41 public function execute(): bool
42 {
43 if (!parent::execute())
44 {
45 return false;
46 }
47
48 if (!isset($this->siteData))
49 {
50 return false;
51 }
52
53 if (
54 $this->isStarted()
55 && $this->applyResponses()
56 )
57 {
58 $this->changed = true;
59 }
60
61 if (!$this->isFinished())
62 {
63 $this->sendRequests();
64 }
65
66 return true;
67 }
68
72 public function isAsync(): bool
73 {
74 return true;
75 }
76
80 public function isStarted(): bool
81 {
82 foreach ($this->getEntitiesToRequest() as $entity)
83 {
84 if (
85 isset($entity->requestId)
86 && isset($this->requests[$entity->requestId])
87 )
88 {
89 return true;
90 }
91 }
92
93 return false;
94 }
95
99 public function isFinished(): bool
100 {
101 if (empty($this->getEntitiesToRequest()))
102 {
103 return true;
104 }
105
106 if (empty($this->requests))
107 {
108 return false;
109 }
110
111 foreach ($this->requests as $request)
112 {
113 if (!$request->isApplied())
114 {
115 return false;
116 }
117 }
118
119 return true;
120 }
121
125 public function clearErrors(): void
126 {
127 foreach ($this->requests as $request)
128 {
129 if (
131 && $request->getError()
132 )
133 {
134 $request->setDeleted();
135 unset($this->requests[$request->getId()]);
136 }
137 }
138 }
139
145 abstract protected function getEntitiesToRequest(): array;
146
152 abstract protected function sendRequests(): bool;
153
159 abstract protected function applyResponses(): bool;
160}
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
static getByGeneration(int $generationId, int $stepId)
Определения Request.php:347
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$entity