Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
settingscontainer.php
1<?
3
6
8{
9 public const BUILDER_SCENARIO_SHIPMENT = 'shipment';
10 public const BUILDER_SCENARIO_PAYMENT = 'payment';
11 public const BUILDER_SCENARIO_RESERVATION = 'reservation';
12
16
17 private $settings;
18
19 protected function getDefaultSettings() : array
20 {
21 return [
22 //Delete clients which is not in the parameters
23 'deleteClientsIfNotExists' => false,
24
25 //Allow creation new user if it doesn't exist yet.
26 'createUserIfNeed' => self::ALLOW_NEW_USER_CREATION,
27
28 // Search existing user on creating user
29 'searchExistingUserOnCreating' => false,
30
31 //Delete tradeBindings which is not in the parameters
32 'deleteTradeBindingIfNotExists' => true,
33 //Delete basketItems which is not in the parameters
34 'deleteBasketItemsIfNotExists' => true,
35 //Delete payment which is not in the parameters
36 'deletePaymentIfNotExists' => false,
37 //Delete shipment which is not in the parameters
38 'deleteShipmentIfNotExists' => false,
39 //Delete shipmentItem which is not in the parameters
40 'deleteShipmentItemIfNotExists' => false,
41 //Delete propertyValues which is not in the parameters
42 'deletePropertyValuesIfNotExists' => false,
43 //Do we need to create a new payment by default, if payments empty?
44 'createDefaultPaymentIfNeed' => true,
45 //Do we need to create a new shipment by default, if shipments empty?
46 'createDefaultShipmentIfNeed' => true,
47 //Do we have to clear reserves for a basket item that doesn't explicitly have any reserve data set in it's product data?
48 'clearReservesIfEmpty' => false,
49
50 //Do we need update the price of just added products.
51 //Now it is used only after the buyerId was changed.
52 'needUpdateNewProductPrice' => false,
53 //Refresh all products data.
54 //Now it is used only during order recalculation
55 'isRefreshData' => false,
56 //For performance purposes
57 'cacheProductProviderData' => true,
58 //Other errors will be ignored.
59 //We need this mostly during order creation
60 //empty means - all acceptable
61 'acceptableErrorCodes' => [],
62 //We need this if some of order properties upload files.
63 'propsFiles' => [],
64 //Fill shipments by FORM_DATA of basket builder
65 'fillShipmentsByBasketBuilder' => false,
66 //Builder scenario
67 'builderScenario' => null,
68 ];
69 }
70
71 public function __construct (array $settings)
72 {
73 $diff = array_diff(
74 array_keys($settings),
75 array_keys($this->getDefaultSettings())
76 );
77
78 if (!empty($diff))
79 {
80 throw new ArgumentOutOfRangeException('Unknown settings: "'.implode('",', $diff).'"');
81 }
82
83 $this->settings = array_merge($this->getDefaultSettings(), $settings);
84 }
85
86 public function getItemValue($name)
87 {
88 if (!isset($this->settings[$name]))
89 {
90 throw new SystemException('Unknown setting: "'.$name.'"');
91 }
92
93 return $this->settings[$name];
94 }
95}