Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
modificationfieldsbase.php
1<?php
2
3
4namespace Bitrix\Sale\Rest;
5
6
10
12{
13 const TO_WHITE_LIST = 'TO_WHITE_LIST';
14 const TO_CAMEL = 'TO_CAMEL';
15 const TO_SNAKE = 'TO_SNAKE';
16 const SORTING_KEYS = 'SORTING_KEYS';
17 const CHECK_REQUIRED = 'CHECK_REQUIRED';
18
19 protected $format;
20 protected $data;
21 protected $scope;
22
23 static public function buildByAction(Action $action, $data=[], $scope='')
24 {
25 return new static($action->getName(), $action->getArguments(), $action->getController(), $data, $scope);
26 }
27
28 public function __construct($name, $arguments, $controller, $data=[], $scope='')
29 {
30 $this->name = $name;
31 $this->arguments = $arguments;
32 $this->controller = $controller;
33
34 $this->data = $data;
35 $this->scope = $scope;
36 }
37
38 public function getName()
39 {
40 return $this->name;
41 }
42
43 public function getArguments()
44 {
45 return $this->arguments;
46 }
47
48 public function setArguments($arguments)
49 {
50 $this->arguments = $arguments;
51 }
52
56 public function setFormat($format): void
57 {
58 $this->format = $format;
59 }
60
61 public function getController()
62 {
63 return $this->controller;
64 }
65
66 public function getScope()
67 {
68 return $this->scope;
69 }
70
71 public function getData()
72 {
73 return $this->data;
74 }
75
81 protected function getEntity(Controller $controller)
82 {
83 $entity = null;
84 if($controller instanceof \Bitrix\Sale\Controller\Order)
85 {
86 $entity = new \Bitrix\Sale\Rest\Entity\Order();
87 }
88 elseif ($controller instanceof \Bitrix\Sale\Controller\BasketItem)
89 {
90 $entity = new \Bitrix\Sale\Rest\Entity\BasketItem();
91 }
92 elseif ($controller instanceof \Bitrix\Sale\Controller\BasketProperties)
93 {
94 $entity = new \Bitrix\Sale\Rest\Entity\BasketProperties();
95 }
96 elseif ($controller instanceof \Bitrix\Sale\Controller\Payment)
97 {
98 $entity = new \Bitrix\Sale\Rest\Entity\Payment();
99 }
100 elseif ($controller instanceof \Bitrix\Sale\Controller\Property)
101 {
102 $entity = new \Bitrix\Sale\Rest\Entity\Property();
103 }
104 elseif ($controller instanceof \Bitrix\Sale\Controller\Shipment)
105 {
106 $entity = new \Bitrix\Sale\Rest\Entity\Shipment();
107 }
108 elseif ($controller instanceof \Bitrix\Sale\Controller\ShipmentItem)
109 {
110 $entity = new \Bitrix\Sale\Rest\Entity\ShipmentItem();
111 }
112 else
113 {
114 throw new RestException('Unknown object ' . get_class($controller));
115 }
116
117 return $entity;
118 }
119}
__construct($name, $arguments, $controller, $data=[], $scope='')
static buildByAction(Action $action, $data=[], $scope='')