Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
businessvalue.php
1<?php
2
4
6
23class BusinessValueTable extends Main\Entity\DataManager
24{
25 public static function getFilePath()
26 {
27 return __FILE__;
28 }
29
30 public static function getTableName()
31 {
32 return 'b_sale_bizval';
33 }
34
36 const COMMON_CONSUMER_KEY = 'COMMON';
37
38 public static function getMap()
39 {
40 return array(
41
42 new Main\Entity\StringField('CODE_KEY', array(
43 'primary' => true,
44 'size' => 50,
45 )),
46
47 new Main\Entity\StringField('CONSUMER_KEY', array(
48 'primary' => true,
49 'size' => 50,
50 'save_data_modification' => function ()
51 {
52 return array(
53 function ($value)
54 {
56 }
57 );
58 },
59 'fetch_data_modification' => function ()
60 {
61 return array(
62 function ($value)
63 {
64 return $value == BusinessValueTable::COMMON_CONSUMER_KEY ? null : $value;
65 }
66 );
67 }
68 )),
69
70 new Main\Entity\IntegerField('PERSON_TYPE_ID', array(
71 'primary' => true,
72 'size' => 50,
73 'save_data_modification' => function ()
74 {
75 return array(
76 function ($value)
77 {
79 }
80 );
81 },
82 'fetch_data_modification' => function ()
83 {
84 return array(
85 function ($value)
86 {
87 return $value == BusinessValueTable::COMMON_PERSON_TYPE_ID ? null : (int) $value;
88 }
89 );
90 }
91 )),
92
93 new Main\Entity\StringField('PROVIDER_KEY', array(
94 'required' => true,
95 'size' => 50,
96 )),
97
98 new Main\Entity\StringField('PROVIDER_VALUE'),
99
100 );
101 }
102
109 public static function deleteByCodeKey(string $codeKey): void
110 {
111 $businessValueIterator = static::getList([
112 'filter' => [
113 '=CODE_KEY' => $codeKey,
114 ],
115 ]);
116 while ($businessValue = $businessValueIterator->fetch())
117 {
118 if ($businessValue['PROVIDER_KEY'] === 'FILE')
119 {
120 \CFile::Delete($businessValue['PROVIDER_VALUE']);
121 }
122
123 static::delete([
124 'CODE_KEY' => $businessValue['CODE_KEY'],
125 'CONSUMER_KEY' => $businessValue['CONSUMER_KEY'] ?? static::COMMON_CONSUMER_KEY,
126 'PERSON_TYPE_ID' => $businessValue['PERSON_TYPE_ID'] ?? static::COMMON_PERSON_TYPE_ID,
127 ]);
128 }
129 }
130}