Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
siterestriction.php
1<?php
3
6use \Bitrix\Main\Localization\Loc;
9
10Loc::loadMessages(__FILE__);
11
16abstract 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 {
118
119 return parent::getSeverity($mode);
120 }
121
125 public static function isAvailable()
126 {
127 return IsModuleInstalled('bitrix24') ? false : true;
128 }
129}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static extractParams(Entity $entity)
static check($siteId, array $restrictionParams, $deliveryId=0)