1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
stepper.php
См. документацию.
1<?php
2namespace Bitrix\Translate\Controller;
3
4use Bitrix\Main;
5use Bitrix\Translate;
6
13{
14 protected ?string $processToken;
15
16 protected bool $isNewProcess = true;
17
18 protected bool $isProcessCompleted = false;
19
20 protected int $processedItems = 0;
21
22 protected int $totalItems = 0;
23
25
26
33 protected function onBeforeRun()
34 {
35 if ($this instanceof IProcessParameters)
36 {
37 $this->keepField([
38 'processedItems',
39 'totalItems',
40 ]);
41
43 $this->processToken = $this->getController()->getRequest()->get('PROCESS_TOKEN');
44
45 $progressData = $this->getProgressParameters();
46 if (\count($progressData) > 0)
47 {
48 $this->isNewProcess = (empty($progressData['processToken']) || $progressData['processToken'] !== $this->processToken);
49 if (!$this->isNewProcess)
50 {
51 // restore state
53 }
54 }
55
56 $this->keepField('processToken');
57 }
58
59 if (empty($this->processToken))
60 {
61 $this->addError(new Main\Error('Process token is not specified.'));
62 }
63
64 return \count($this->getErrors()) === 0;
65 }
66
75 protected function performStep($action, array $params = [])
76 {
77 if ($this->isNewProcess)
78 {
79 $this->processedItems = 0;
80 $this->totalItems = 0;
81
82 if ($this instanceof IProcessParameters)
83 {
85 }
86 }
87
88 $this->startTimer();
89
90 if ($action instanceof \Closure)
91 {
92 $result = $action->call($this, $params);
93 }
94 elseif (\is_callable($action))
95 {
96 $result = \call_user_func($action, $params);
97 }
98 elseif (\is_string($action) && \is_callable([$this, $action]))
99 {
100 $result = \call_user_func([$this, $action], $params);
101 }
102 else
103 {
104 $this->addError(new Main\Error('Wrong action parameter!'));
105 }
106
107 if ($this->hasErrors())
108 {
110 }
111 elseif ($this->hasProcessCompleted())
112 {
114 }
115 else
116 {
118 }
119
120 if ($this instanceof IProcessParameters)
121 {
122 // Save progress
123 $this->saveProgressParameters();
124 }
125
126 return $result;
127 }
128
136 public function declareAccomplishment(bool $flag = true): void
137 {
138 $this->isProcessCompleted = $flag;
139 }
140
146 public function hasProcessCompleted(): bool
147 {
148 return $this->isProcessCompleted;
149 }
150
151
156 public function hasErrors(): bool
157 {
159 if ($this->errorCollection instanceof Main\ErrorCollection)
160 {
161 return $this->errorCollection->isEmpty() !== true;
162 }
163
164 return false;
165 }
166
173 {
174 if ($this->timer === null)
175 {
176 $this->timer = new Translate\Controller\Timer();
177 }
178
179 return $this->timer;
180 }
181
189 public function startTimer(): void
190 {
191 $this->instanceTimer()->startTimer((int)\START_EXEC_TIME);
192 }
193
201 public function hasTimeLimitReached(): bool
202 {
203 return $this->instanceTimer()->hasTimeLimitReached();
204 }
205}
Определения error.php:15
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
const START_EXEC_TIME
Определения start.php:12
getErrors()
Определения errorableimplementation.php:34
hasErrors()
Определения errorableimplementation.php:17
bool $isProcessCompleted
Определения stepper.php:18
restoreProgressParameters()
Определения processparams.php:72
const STATUS_COMPLETED
Определения controller.php:6
instanceTimer()
Определения stepper.php:172
bool $isNewProcess
Определения stepper.php:16
Translate Controller Timer $timer
Определения stepper.php:24
hasProcessCompleted()
Определения stepper.php:146
int $processedItems
Определения stepper.php:20
int $totalItems
Определения stepper.php:22
hasTimeLimitReached()
Определения stepper.php:201
performStep($action, array $params=[])
Определения stepper.php:75
declareAccomplishment(bool $flag=true)
Определения stepper.php:136
trait Stepper
Определения stepper.php:13
saveProgressParameters()
Определения processparams.php:97
keepField($fieldName)
Определения processparams.php:53
const STATUS_PROGRESS
Определения controller.php:7
Определения autoload.php:3
addError(Main\Error $error)
Определения error.php:22
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$action
Определения file_dialog.php:21