Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
agentcontractfiletable.php
1<?php
2
3namespace Bitrix\Catalog;
4
6use Bitrix\Main\Entity\EventResult;
12
40{
46 public static function getTableName(): string
47 {
48 return 'b_catalog_agent_contract_file';
49 }
50
56 public static function getMap(): array
57 {
58 return [
59 'ID' => new IntegerField(
60 'ID',
61 [
62 'primary' => true,
63 'autocomplete' => true,
64 'title' => Loc::getMessage('AGENT_CONTRACT_FILE_ENTITY_ID_FIELD'),
65 ]
66 ),
67 'CONTRACT_ID' => new IntegerField(
68 'CONTRACT_ID',
69 [
70 'required' => true,
71 'title' => Loc::getMessage('AGENT_CONTRACT_FILE_ENTITY_CONTRACT_ID_FIELD'),
72 ]
73 ),
74 'CONTRACT' => new Reference(
75 'CONTRACT',
76 '\Bitrix\Catalog\AgentContractTable',
77 ['=this.CONTRACT_ID' => 'ref.ID'],
78 ),
79 'FILE_ID' => new IntegerField(
80 'FILE_ID',
81 [
82 'required' => true,
83 'title' => Loc::getMessage('AGENT_CONTRACT_FILE_ENTITY_FILE_ID_FIELD'),
84 ]
85 ),
86 'FILE' => new Reference(
87 'FILE',
88 '\Bitrix\Main\FileTable',
89 ['=this.FILE_ID' => 'ref.ID'],
90 ),
91 ];
92 }
93
94 public static function deleteFilesByContractId(int $contractId): void
95 {
96 $agentContractFileIterator = self::getList([
97 'select' => ['ID', 'FILE_ID'],
98 'filter' => ['=CONTRACT_ID' => $contractId],
99 ]);
100 while ($agentContractFile = $agentContractFileIterator->fetch())
101 {
102 \CFile::Delete($agentContractFile['FILE_ID']);
103 self::delete($agentContractFile['ID']);
104 }
105 }
106}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getList(array $parameters=array())