Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
workflowtemplate.php
1
<?php
2
namespace
Bitrix\Bizproc\Copy\Implement
;
3
4
use
Bitrix\Main\Error
;
5
use
Bitrix\Main\Result
;
6
7
class
WorkflowTemplate
8
{
9
const
WORKFLOW_TEMPLATE_COPY_ERROR
=
'WORKFLOW_TEMPLATE_COPY_ERROR'
;
10
11
protected
$targetDocumentType
= [];
12
protected
$mapStatusIdsCopiedDocument
= [];
13
14
protected
$result
;
15
16
public
function
__construct
(
$targetDocumentType
= [],
$mapStatusIdsCopiedDocument
= [])
17
{
18
$this->targetDocumentType =
$targetDocumentType
;
19
$this->mapStatusIdsCopiedDocument =
$mapStatusIdsCopiedDocument
;
20
21
$this->result =
new
Result
();
22
}
23
24
public
function
getFields
($workflowTemplateId)
25
{
26
$queryResult = \CBPWorkflowTemplateLoader::getList([], [
'ID'
=> $workflowTemplateId]);
27
return
(($fields = $queryResult->fetch()) ? $fields : []);
28
}
29
30
public
function
prepareFieldsToCopy
(array $fields)
31
{
32
if
(isset($fields[
'ID'
]))
33
{
34
unset($fields[
'ID'
]);
35
}
36
37
if
($this->targetDocumentType)
38
{
39
$fields[
'DOCUMENT_TYPE'
] =
$this->targetDocumentType
;
40
}
41
42
if
(array_key_exists($fields[
'DOCUMENT_STATUS'
], $this->mapStatusIdsCopiedDocument))
43
{
44
$fields[
'DOCUMENT_STATUS'
] = $this->mapStatusIdsCopiedDocument[$fields[
'DOCUMENT_STATUS'
]];
45
}
46
47
return
$fields;
48
}
49
50
public
function
add
(array $fields)
51
{
52
$result
=
false
;
53
54
if
($fields)
55
{
56
$result
= \CBPWorkflowTemplateLoader::add($fields,
true
);
57
}
58
59
if
(!
$result
)
60
{
61
$this->result->addError(
62
new
Error
(
'Failed to copy workflow template'
, self::WORKFLOW_TEMPLATE_COPY_ERROR)
63
);
64
}
65
66
return
$result
;
67
}
68
}
Bitrix\Bizproc\Copy\Implement\WorkflowTemplate
Definition
workflowtemplate.php:8
Bitrix\Bizproc\Copy\Implement\WorkflowTemplate\$result
$result
Definition
workflowtemplate.php:14
Bitrix\Bizproc\Copy\Implement\WorkflowTemplate\getFields
getFields($workflowTemplateId)
Definition
workflowtemplate.php:24
Bitrix\Bizproc\Copy\Implement\WorkflowTemplate\add
add(array $fields)
Definition
workflowtemplate.php:50
Bitrix\Bizproc\Copy\Implement\WorkflowTemplate\$targetDocumentType
$targetDocumentType
Definition
workflowtemplate.php:11
Bitrix\Bizproc\Copy\Implement\WorkflowTemplate\$mapStatusIdsCopiedDocument
$mapStatusIdsCopiedDocument
Definition
workflowtemplate.php:12
Bitrix\Bizproc\Copy\Implement\WorkflowTemplate\__construct
__construct($targetDocumentType=[], $mapStatusIdsCopiedDocument=[])
Definition
workflowtemplate.php:16
Bitrix\Bizproc\Copy\Implement\WorkflowTemplate\prepareFieldsToCopy
prepareFieldsToCopy(array $fields)
Definition
workflowtemplate.php:30
Bitrix\Bizproc\Copy\Implement\WorkflowTemplate\WORKFLOW_TEMPLATE_COPY_ERROR
const WORKFLOW_TEMPLATE_COPY_ERROR
Definition
workflowtemplate.php:9
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\Result
Definition
result.php:14
Bitrix\Bizproc\Copy\Implement
Definition
trigger.php:2
modules
bizproc
lib
copy
implement
workflowtemplate.php
Создано системой
1.10.0