1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
route.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\UrlPreview;
4
5use Bitrix\Main\Application;
6use Bitrix\Main;
7use Bitrix\Main\ORM\Data\AddResult;
8use Bitrix\Main\ORM\Data\DataManager;
9use Bitrix\Main\ORM\Fields;
10
28{
34 public static function getTableName()
35 {
36 return 'b_urlpreview_route';
37 }
38
44 public static function getMap()
45 {
46 return array(
47 'ID' => new Fields\IntegerField('ID', array(
48 'primary' => true,
49 'autocomplete' => true,
50 )),
51 'ROUTE' => new Fields\StringField('ROUTE', array(
52 'required' => true,
53 'unique' => true
54 )),
55 'MODULE' => new Fields\StringField('MODULE', array(
56 'required' => true,
57 )),
58 'CLASS' => new Fields\StringField('CLASS', array(
59 'required' => true,
60 )),
61 'PARAMETERS' => new Fields\TextField('PARAMETERS', array(
62 'serialized' => true,
63 )),
64 );
65 }
66
74 public static function getByRoute($route)
75 {
76 $parameters = array(
77 'select' => array('*'),
78 'filter' => array(
79 '=ROUTE' => $route,
80 )
81 );
82
83 return static::getList($parameters)->fetch();
84 }
85
92 public static function merge(array $data)
93 {
94 $result = new AddResult();
95
96 try
97 {
98 // set fields with default values
99 foreach (static::getEntity()->getFields() as $field)
100 {
101 if ($field instanceof Fields\ScalarField && !array_key_exists($field->getName(), $data))
102 {
103 $defaultValue = $field->getDefaultValue();
104
105 if ($defaultValue !== null)
106 {
107 $data[$field->getName()] = $field->getDefaultValue();
108 }
109 }
110 }
111
112 static::checkFields($result, null, $data);
113
114 // use save modifiers
115 foreach ($data as $fieldName => $value)
116 {
117 $field = static::getEntity()->getField($fieldName);
118 $data[$fieldName] = $field->modifyValueBeforeSave($value, $data);
119 }
120
121 $helper = Application::getConnection()->getSqlHelper();
122 $insertData = $data;
123 $updateData = $data;
124 unset($updateData['ROUTE']);
125 $merge = $helper->prepareMerge(
126 static::getTableName(),
127 array("ROUTE"),
128 $insertData,
129 $updateData
130 );
131
132 if ($merge[0] != "")
133 {
134 Application::getConnection()->query($merge[0]);
135 $id = Application::getConnection()->getInsertedId();
136 if($id == 0)
137 {
138 $updatedRecord = static::getByRoute($data['ROUTE']);
139 $id = $updatedRecord['ID'];
140 }
141 $result->setId($id);
142 $result->setData($data);
143 }
144 else
145 {
146 $result->addError(new Main\Error('Error constructing query'));
147 }
148 }
149 catch (\Exception $e)
150 {
151 // check result to avoid warning
152 $result->isSuccess();
153
154 throw $e;
155 }
156
157 return $result;
158 }
159}
if($_SERVER $defaultValue['REQUEST_METHOD']==="GET" &&!empty($RestoreDefaults) && $bizprocPerms==="W" &&check_bitrix_sessid())
Определения options.php:32
static getConnection($name="")
Определения application.php:638
Определения error.php:15
static getMap()
Определения route.php:44
static getByRoute($route)
Определения route.php:74
static merge(array $data)
Определения route.php:92
static getTableName()
Определения route.php:34
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$route
Определения routing_index.php:35