1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
AbstractCommand.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
6
12
13abstract class AbstractCommand implements CommandInterface
14{
18 final public function run(): Result
19 {
20 $validationResult = $this->validate();
21 if (!$validationResult->isSuccess())
22 {
23 throw new CommandValidationException($validationResult->getErrors());
24 }
25
26 if ($errorResult = $this->beforeRun())
27 {
28 return $errorResult;
29 }
30
31 try
32 {
33 $result = $this->execute();
34 }
35 catch (\Exception $e)
36 {
37 throw new CommandException($this, 'Command has unprocessed exception', previous: $e);
38 }
39
40 $this->afterRun();
41
42 return $result;
43 }
44
45 abstract protected function execute(): Result;
46
47 protected function validate(): ValidationResult
48 {
49 return ServiceLocator::getInstance()->get('main.validation.service')->validate($this);
50 }
51
55 protected function beforeRun(): ?Result
56 {
57 return null;
58 }
59
60 protected function afterRun(): void
61 {
62 }
63}
$result
Определения get_property_values.php:14