Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
settingscontainer.php
1
<?
2
namespace
Bitrix\Sale\Helpers\Order\Builder
;
3
4
use
Bitrix\Main\ArgumentOutOfRangeException
;
5
use
Bitrix\Main\SystemException
;
6
7
class
SettingsContainer
8
{
9
public
const
BUILDER_SCENARIO_SHIPMENT
=
'shipment'
;
10
public
const
BUILDER_SCENARIO_PAYMENT
=
'payment'
;
11
public
const
BUILDER_SCENARIO_RESERVATION
=
'reservation'
;
12
13
const
DISALLOW_NEW_USER_CREATION
= 0;
14
const
ALLOW_NEW_USER_CREATION
= 1;
15
const
SET_ANONYMOUS_USER
= 2;
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
}
Bitrix\Main\ArgumentOutOfRangeException
Definition
exception.php:67
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Sale\Helpers\Order\Builder\SettingsContainer
Definition
settingscontainer.php:8
Bitrix\Sale\Helpers\Order\Builder\SettingsContainer\getItemValue
getItemValue($name)
Definition
settingscontainer.php:86
Bitrix\Sale\Helpers\Order\Builder\SettingsContainer\DISALLOW_NEW_USER_CREATION
const DISALLOW_NEW_USER_CREATION
Definition
settingscontainer.php:13
Bitrix\Sale\Helpers\Order\Builder\SettingsContainer\getDefaultSettings
getDefaultSettings()
Definition
settingscontainer.php:19
Bitrix\Sale\Helpers\Order\Builder\SettingsContainer\BUILDER_SCENARIO_SHIPMENT
const BUILDER_SCENARIO_SHIPMENT
Definition
settingscontainer.php:9
Bitrix\Sale\Helpers\Order\Builder\SettingsContainer\__construct
__construct(array $settings)
Definition
settingscontainer.php:71
Bitrix\Sale\Helpers\Order\Builder\SettingsContainer\SET_ANONYMOUS_USER
const SET_ANONYMOUS_USER
Definition
settingscontainer.php:15
Bitrix\Sale\Helpers\Order\Builder\SettingsContainer\BUILDER_SCENARIO_PAYMENT
const BUILDER_SCENARIO_PAYMENT
Definition
settingscontainer.php:10
Bitrix\Sale\Helpers\Order\Builder\SettingsContainer\BUILDER_SCENARIO_RESERVATION
const BUILDER_SCENARIO_RESERVATION
Definition
settingscontainer.php:11
Bitrix\Sale\Helpers\Order\Builder\SettingsContainer\ALLOW_NEW_USER_CREATION
const ALLOW_NEW_USER_CREATION
Definition
settingscontainer.php:14
Bitrix\Sale\Helpers\Order\Builder
Definition
basketbuilder.php:2
modules
sale
lib
helpers
order
builder
settingscontainer.php
Создано системой
1.10.0