Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sourcetype.php
1<?php
2
4
6{
7 const DocumentField = 'Document';
8 const Parameter = 'Parameter';
9 const Variable = 'Variable';
10 const Constant = 'Constant';
11 const GlobalConstant = 'GlobalConst';
12 const GlobalVariable = 'GlobalVar';
13 const System = 'System';
14 const Activity = 'Activity';
15 const CalcFunction = 'Function';
16
17 public static function isType($type)
18 {
19 $ref = new \ReflectionClass(__CLASS__);
20 $constants = array_flip($ref->getConstants());
21
22 return (isset($constants[$type]));
23 }
24
25 public static function getObjectSourceType($objectName, $fieldName): ?array
26 {
27 if (mb_substr($fieldName, -10) === '_printable')
28 {
29 $fieldName = mb_substr($fieldName, 0, -10);
30 }
31
32 if ($objectName === static::DocumentField)
33 {
34 return [static::DocumentField, $fieldName];
35 }
36 elseif ($objectName === 'Template' || $objectName === static::Parameter)
37 {
38 return [static::Parameter, $fieldName];
39 }
40 elseif ($objectName === static::Variable)
41 {
42 return [static::Variable, $fieldName];
43 }
44 elseif ($objectName === static::Constant)
45 {
46 return [static::Constant, $fieldName];
47 }
48 elseif ($objectName === static::GlobalConstant)
49 {
50 return [static::GlobalConstant, $fieldName];
51 }
52 elseif ($objectName === static::GlobalVariable)
53 {
54 return [static::GlobalVariable, $fieldName];
55 }
56 elseif (in_array($objectName, ['Workflow', 'User', static::System]))
57 {
58 // ['System', 'User', 'Id'] => User:Id
59 return [static::System, $objectName, $fieldName];
60 }
61 elseif ($objectName)
62 {
63 // ['Activity', 'A49308_81258_73524_17187', 'TITLE'] => A49308_81258_73524_17187:TITLE
64 return [static::Activity, $objectName, $fieldName];
65 }
66
67 return null;
68 }
69}
static getObjectSourceType($objectName, $fieldName)