Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
templatesscheme.php
1
<?php
2
3
namespace
Bitrix\Bizproc\Automation\Engine
;
4
5
use
Bitrix\Main\Error
;
6
use
Bitrix\Main\Localization\Loc
;
7
use
Bitrix\Main\Result
;
8
9
abstract
class
TemplatesScheme
10
{
11
public
const
ERROR_CODE_MISSING_TEMPLATE_ERROR
=
'TEMPLATES_SCHEME_ERROR_CODE_TEMPLATE_ERROR'
;
12
public
const
ERROR_CODE_GETTING_TEMPLATE_ERROR
=
'TEMPLATES_SCHEME_ERROR_CODE_TEMPLATE_ERROR'
;
13
15
private
$scheme = [];
16
17
public
function
isAutomationAvailable
(array $complexDocumentType): bool
18
{
19
return
true
;
20
}
21
22
public
function
addTemplate
(
TemplateScope
$scope)
23
{
24
$this->scheme[$scope->
getId
()] = $scope;
25
}
26
27
public
function
getTemplate
(
TemplateScope
$scope): ?
Template
28
{
29
if
($this->
hasTemplate
($scope))
30
{
31
return
new
Template
($scope->
getComplexDocumentType
(), $scope->
getStatusId
());
32
}
33
34
return
null
;
35
}
36
37
public
function
toArray
(): array
38
{
39
$scheme = [];
40
foreach
($this->scheme as $scopeId => $scope)
41
{
42
$scheme[$scopeId] = $scope->toArray();
43
}
44
45
return
$scheme;
46
}
47
48
protected
function
hasTemplate
(
TemplateScope
$scope): bool
49
{
50
return
isset($this->scheme[$scope->
getId
()]);
51
}
52
53
public
function
createTemplatesTunnel
(
TemplateScope
$srcScope,
TemplateScope
$dstScope):
Result
54
{
55
$result =
new
Result
();
56
if
(!$this->
hasTemplate
($srcScope) || !$this->
hasTemplate
($dstScope))
57
{
58
$errorMessage =
Loc::getMessage
(
'BIZPROC_AUTOMATION_SCHEME_TEMPLATE_ERROR'
);
59
$result->addError(
new
Error
($errorMessage, self::ERROR_CODE_MISSING_TEMPLATE_ERROR));
60
}
61
62
$srcTemplate = $srcScope->
getTemplate
();
63
$dstTemplate = $dstScope->
getTemplate
();
64
65
if
(
66
is_null($srcTemplate)
67
|| is_null($dstTemplate)
68
)
69
{
70
$errorMessage =
Loc::getMessage
(
'BIZPROC_AUTOMATION_SCHEME_TEMPLATE_ERROR'
);
71
$result->addError(
new
Error
($errorMessage, self::ERROR_CODE_GETTING_TEMPLATE_ERROR));
72
}
73
elseif ($result->isSuccess())
74
{
75
$result->setData([
'templatesTunnel'
=>
new
TemplatesTunnel
($srcTemplate, $dstTemplate)]);
76
}
77
78
return
$result;
79
}
80
81
abstract
public
function
build
(): void;
82
}
Bitrix\Bizproc\Automation\Engine\Template
Definition
template.php:22
Bitrix\Bizproc\Automation\Engine\TemplateScope
Definition
templatescope.php:11
Bitrix\Bizproc\Automation\Engine\TemplateScope\getId
getId()
Definition
templatescope.php:62
Bitrix\Bizproc\Automation\Engine\TemplateScope\getStatusId
getStatusId()
Definition
templatescope.php:92
Bitrix\Bizproc\Automation\Engine\TemplateScope\getTemplate
getTemplate()
Definition
templatescope.php:33
Bitrix\Bizproc\Automation\Engine\TemplateScope\getComplexDocumentType
getComplexDocumentType()
Definition
templatescope.php:82
Bitrix\Bizproc\Automation\Engine\TemplatesScheme
Definition
templatesscheme.php:10
Bitrix\Bizproc\Automation\Engine\TemplatesScheme\ERROR_CODE_GETTING_TEMPLATE_ERROR
const ERROR_CODE_GETTING_TEMPLATE_ERROR
Definition
templatesscheme.php:12
Bitrix\Bizproc\Automation\Engine\TemplatesScheme\isAutomationAvailable
isAutomationAvailable(array $complexDocumentType)
Definition
templatesscheme.php:17
Bitrix\Bizproc\Automation\Engine\TemplatesScheme\ERROR_CODE_MISSING_TEMPLATE_ERROR
const ERROR_CODE_MISSING_TEMPLATE_ERROR
Definition
templatesscheme.php:11
Bitrix\Bizproc\Automation\Engine\TemplatesScheme\build
build()
Bitrix\Bizproc\Automation\Engine\TemplatesScheme\hasTemplate
hasTemplate(TemplateScope $scope)
Definition
templatesscheme.php:48
Bitrix\Bizproc\Automation\Engine\TemplatesScheme\createTemplatesTunnel
createTemplatesTunnel(TemplateScope $srcScope, TemplateScope $dstScope)
Definition
templatesscheme.php:53
Bitrix\Bizproc\Automation\Engine\TemplatesScheme\toArray
toArray()
Definition
templatesscheme.php:37
Bitrix\Bizproc\Automation\Engine\TemplatesScheme\addTemplate
addTemplate(TemplateScope $scope)
Definition
templatesscheme.php:22
Bitrix\Bizproc\Automation\Engine\TemplatesScheme\getTemplate
getTemplate(TemplateScope $scope)
Definition
templatesscheme.php:27
Bitrix\Bizproc\Automation\Engine\TemplatesTunnel
Definition
templatestunnel.php:10
Bitrix\Bizproc\Error
Definition
error.php:8
Bitrix\Bizproc\Result
Definition
result.php:6
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Bizproc\Automation\Engine
Definition
condition.php:2
modules
bizproc
lib
automation
engine
templatesscheme.php
Создано системой
1.10.0