Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
grouphelper.php
1<?
10
12
14{
15 const LIST_PAGE_URL = 'sale_location_group_list.php';
16 const EDIT_PAGE_URL = 'sale_location_group_edit.php';
17
18 #####################################
19 #### Entity settings
20 #####################################
21
27 public static function getEntityRoadMap()
28 {
29 return array(
30 'main' => array(
31 'name' => 'Bitrix\Sale\Location\Group',
32 ),
33 'name' => array(
34 'name' => 'Bitrix\Sale\Location\Name\Group',
35 'pages' => array(
36 'list' => array(
37 'includedColumns' => array('NAME')
38 ),
39 'detail' => array(
40 'includedColumns' => array('NAME')
41 )
42 )
43 ),
44 'link' => array(
45 'name' => 'Bitrix\Sale\Location\GroupLocation',
46 ),
47 );
48 }
49
50 #####################################
51 #### CRUD wrappers
52 #####################################
53
54 public static function add($data)
55 {
56 $loc = $data['LOC'];
57 unset($data['LOC']);
58
59 $result = parent::add($data);
60 if($result['success'])
61 {
62 $entityClass = static::getEntityClass('link');
63 $loc = self::prepareLinksForSaving($entityClass, $loc);
64
65 $entityClass::resetMultipleForOwner($result['id'], $loc);
66 }
67
68 return $result;
69 }
70
71 public static function update($gId, $data)
72 {
73 $loc = $data['LOC'];
74 unset($data['LOC']);
75
76 $result = parent::update($gId, $data);
77 if($result['success'])
78 {
79 $entityClass = static::getEntityClass('link');
80 $loc = self::prepareLinksForSaving($entityClass, $loc);
81
82 $entityClass::resetMultipleForOwner($gId, $loc);
83 }
84
85 return $result;
86 }
87
88 public static function updateFields($gId, $data)
89 {
90 return parent::update($gId, $data);
91 }
92
93 public static function delete($gId)
94 {
95 $result = parent::delete($gId);
96 if($result['success'])
97 {
98 // update also locations
99 $entityClass = static::getEntityClass('link');
100 $entityClass::deleteAllForOwner($gId); // we should also remove links when removing group (for other entities this is not always so)
101 }
102
103 return $result;
104 }
105}