Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
baseapiobject.php
1<?
2
4
6{
7 const TYPE_CODE = '';
8
10 protected $request;
11
13 protected $service;
14
15 protected static $listRowMap = array();
16
17 public static function normalizeListRow(array $row)
18 {
19 $return = array();
20 foreach(static::$listRowMap as $key => $value)
21 {
22 if (is_array($value))
23 {
24 $return[$key] = $value;
25 }
26 else
27 {
28 $return[$key] = $row[$value];
29 }
30 }
31
32 return $return;
33 }
34
35 public function __construct()
36 {
37 $this->request = Request::create(static::TYPE_CODE);
38 $this->request->setUseDirectQuery($this instanceof IRequestDirectly);
39 }
40
44 public function getRequest()
45 {
46 return $this->request;
47 }
48
49 public function setRequest(Request $request)
50 {
51 $this->request = $request;
52 return $this;
53 }
54
61 public static function create($type, $parameters = null, IService $service = null)
62 {
63 $instance = Factory::create(get_called_class(), $type, $parameters);
64 if ($service)
65 {
66 $instance->setService($service);
67 }
68
69 return $instance;
70 }
71
72 public function setService(IService $service)
73 {
74 $this->service = $service;
75 $this->request->setAuthAdapter($this->service->getAuthAdapter(static::TYPE_CODE));
76
77 return $this;
78 }
79}
static create($type, $parameters=null, IService $service=null)
static create($object, $type, $parameters=null)
Definition factory.php:9