1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
AbstractCommand.php
См. документацию.
1
<?php
2
3
declare(strict_types=1);
4
5
namespace
Bitrix\Main\Command
;
6
7
use
Bitrix\Main\Command\Exception\CommandException
;
8
use
Bitrix\Main\Command\Exception\CommandValidationException
;
9
use
Bitrix\Main\DI\ServiceLocator
;
10
use
Bitrix\Main\Result
;
11
use
Bitrix\Main\Validation\ValidationResult
;
12
13
abstract
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
}
Bitrix\Main\Command\AbstractCommand
Определения
AbstractCommand.php:14
Bitrix\Main\Command\AbstractCommand\validate
validate()
Определения
AbstractCommand.php:47
Bitrix\Main\Command\AbstractCommand\execute
execute()
Bitrix\Main\Command\AbstractCommand\beforeRun
beforeRun()
Определения
AbstractCommand.php:55
Bitrix\Main\Command\AbstractCommand\afterRun
afterRun()
Определения
AbstractCommand.php:60
Bitrix\Main\Command\AbstractCommand\run
run()
Определения
AbstractCommand.php:18
Bitrix\Main\Command\Exception\CommandException
Определения
CommandException.php:11
Bitrix\Main\Command\Exception\CommandValidationException
Определения
CommandValidationException.php:12
Bitrix\Main\DI\ServiceLocator
Определения
servicelocator.php:19
Bitrix\Main\ORM\Data\Result
Определения
result.php:16
Bitrix\Main\Validation\ValidationResult
Определения
ValidationResult.php:10
$result
$result
Определения
get_property_values.php:14
Bitrix\Main\Command\CommandInterface
Определения
CommandInterface.php:12
Bitrix\Main\Command\Exception
Определения
CommandException.php:5
Bitrix\Main\Command
Определения
AbstractCommand.php:5
bitrix
modules
main
lib
Command
AbstractCommand.php
Создано системой
1.14.0