Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
siterestriction.php
1
<?php
2
namespace
Bitrix\Sale\Services\Base
;
3
4
use
Bitrix\Main\NotImplementedException
;
5
use
Bitrix\Sale\Delivery\Restrictions\Base
;
6
use \Bitrix\Main\Localization\Loc;
7
use
Bitrix\Sale\Internals\Entity
;
8
use
Bitrix\Sale\Order
;
9
10
Loc::loadMessages
(__FILE__);
11
16
abstract
class
SiteRestriction
extends
Restriction
17
{
21
public
static
function
getClassTitle
()
22
{
23
return
Loc::getMessage
(
"SALE_SRV_RSTR_BY_SITE_NAME"
);
24
}
25
29
public
static
function
getClassDescription
()
30
{
31
return
Loc::getMessage
(
"SALE_RV_RSTR_BY_SITE_DESCRIPT"
);
32
}
33
34
public
static
function
getOnApplyErrorMessage
(): string
35
{
36
return
Loc::getMessage
(
'SALE_SRV_RSTR_BY_SITE_ON_APPLY_ERROR_MSG'
);
37
}
38
45
public
static
function
check
($siteId, array $restrictionParams, $deliveryId = 0)
46
{
47
if
(empty($restrictionParams))
48
return
true
;
49
50
$result =
true
;
51
52
if
($siteId <>
''
&& isset($restrictionParams[
"SITE_ID"
]) && is_array($restrictionParams[
"SITE_ID"
]))
53
$result = in_array($siteId, $restrictionParams[
"SITE_ID"
]);
54
55
return
$result;
56
}
57
62
protected
static
function
getOrder
(
Entity
$entity)
63
{
64
throw
new
NotImplementedException
(
'Method '
.__METHOD__.
' must be overload'
);
65
}
66
72
protected
static
function
extractParams
(
Entity
$entity)
73
{
75
$order = static::getOrder($entity);
76
77
if
(!$order)
78
return
false
;
79
80
return
$order->getSiteId();
81
}
82
90
public
static
function
getParamsStructure
($entityId = 0)
91
{
92
$siteList = array();
93
94
$rsSite = \Bitrix\Main\SiteTable::getList();
95
96
while
($site = $rsSite->fetch())
97
$siteList[$site[
"LID"
]] = $site[
"NAME"
].
" ("
.$site[
"LID"
].
")"
;
98
99
return
array(
100
"SITE_ID"
=> array(
101
"TYPE"
=>
"ENUM"
,
102
'MULTIPLE'
=>
'Y'
,
103
"DEFAULT"
=> SITE_ID,
104
"LABEL"
=>
Loc::getMessage
(
"SALE_DLVR_RSTR_BY_SITE_SITE_ID"
),
105
"OPTIONS"
=> $siteList
106
)
107
);
108
}
109
114
public
static
function
getSeverity
($mode)
115
{
116
if
($mode ==
RestrictionManager::MODE_MANAGER
)
117
return
RestrictionManager::SEVERITY_STRICT
;
118
119
return
parent::getSeverity($mode);
120
}
121
125
public
static
function
isAvailable
()
126
{
127
return
IsModuleInstalled(
'bitrix24'
) ? false :
true
;
128
}
129
}
Bitrix\Catalog\Model\Entity
Definition
entity.php:12
Bitrix\Catalog\Product\Store\DistributionStrategy\Base
Definition
base.php:21
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\NotImplementedException
Definition
exception.php:147
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Sale\Helpers\Order
Definition
order.php:10
Bitrix\Sale\Services\Base\Restriction
Definition
restriction.php:17
Bitrix\Sale\Services\Base\Restriction\extractParams
static extractParams(Entity $entity)
Definition
restriction.php:115
Bitrix\Sale\Services\Base\RestrictionManager\MODE_MANAGER
const MODE_MANAGER
Definition
restrictionmanager.php:27
Bitrix\Sale\Services\Base\RestrictionManager\SEVERITY_STRICT
const SEVERITY_STRICT
Definition
restrictionmanager.php:31
Bitrix\Sale\Services\Base\SiteRestriction
Definition
siterestriction.php:17
Bitrix\Sale\Services\Base\SiteRestriction\getClassTitle
static getClassTitle()
Definition
siterestriction.php:21
Bitrix\Sale\Services\Base\SiteRestriction\isAvailable
static isAvailable()
Definition
siterestriction.php:125
Bitrix\Sale\Services\Base\SiteRestriction\getClassDescription
static getClassDescription()
Definition
siterestriction.php:29
Bitrix\Sale\Services\Base\SiteRestriction\getOrder
static getOrder(Entity $entity)
Definition
siterestriction.php:62
Bitrix\Sale\Services\Base\SiteRestriction\getOnApplyErrorMessage
static getOnApplyErrorMessage()
Definition
siterestriction.php:34
Bitrix\Sale\Services\Base\SiteRestriction\getParamsStructure
static getParamsStructure($entityId=0)
Definition
siterestriction.php:90
Bitrix\Sale\Services\Base\SiteRestriction\check
static check($siteId, array $restrictionParams, $deliveryId=0)
Definition
siterestriction.php:45
Bitrix\Sale\Services\Base\SiteRestriction\getSeverity
static getSeverity($mode)
Definition
siterestriction.php:114
Bitrix\Sale\Services\Base
Definition
concreteproductrestriction.php:3
modules
sale
lib
services
base
siterestriction.php
Создано системой
1.10.0