Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
ap.php
1<?php
3
5
36class ApTable extends Main\Entity\DataManager
37{
43 public static function getTableName()
44 {
45 return 'b_socialservices_ap';
46 }
47
53 public static function getMap()
54 {
55 return array(
56 'ID' => array(
57 'data_type' => 'integer',
58 'primary' => true,
59 'autocomplete' => true,
60 ),
61 'TIMESTAMP_X' => array(
62 'data_type' => 'datetime',
63 ),
64 'USER_ID' => array(
65 'data_type' => 'integer',
66 'required' => true,
67 ),
68 'DOMAIN' => array(
69 'data_type' => 'string',
70 ),
71 'ENDPOINT' => array(
72 'data_type' => 'string',
73 ),
74 'LOGIN' => array(
75 'data_type' => 'string',
76 ),
77 'PASSWORD' => array(
78 'data_type' => 'string',
79 ),
80 'LAST_AUTHORIZE' => array(
81 'data_type' => 'datetime',
82 ),
83 'SETTINGS' => array(
84 'data_type' => 'string',
85 'serialized' => true,
86 ),
87 );
88 }
89
90 public static function onBeforeUpdate(Main\Entity\Event $event)
91 {
92 $result = new Main\Entity\EventResult();
93
94 $data = $event->getParameter("fields");
95
96 // modify TIMESTAMP_X for every change other than single LAST_AUTHORIZE update
97 if(count($data) > 1 || !array_key_exists('LAST_AUTHORIZE', $data))
98 {
99 $data['TIMESTAMP_X'] = new Main\Type\DateTime();
100 $result->modifyFields($data);
101 }
102
103 return $result;
104 }
105
106 public static function getConnection()
107 {
108 $dbRes = static::getList(array(
109 'order' => array('ID' => 'DESC'),
110 'limit' => 1,
111 'cache' => ['ttl' => 3600],
112 ));
113
114 return $dbRes->fetch();
115 }
116}
static onBeforeUpdate(Main\Entity\Event $event)
Definition ap.php:90