Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
hook.php
1<?php
3
4use \Bitrix\Bitrix24\Feature;
5
6class Hook
7{
11 const MAP = [
12 'gtm' => 'limit_sites_google_analytics',
13 'gacounter' => 'limit_sites_google_analytics',
14 'yacounter' => 'limit_sites_google_analytics',
15 'copyright' => 'limit_sites_powered_by',
16 'headblock' => 'limit_sites_html_js',
17 'theme' => 'limit_sites_change_color_palette',
18 ];
19
25 public static function getRestrictionCodeByHookCode(string $hookCode): ?string
26 {
27 $hookCode = strtolower($hookCode);
28 return isset(self::MAP[$hookCode]) ? self::MAP[$hookCode] : null;
29 }
30
36 public static function isHookAllowed(string $hookCode): bool
37 {
38 $hookCode = strtolower($hookCode);
39 if (isset(self::MAP[$hookCode]))
40 {
41 return self::isAllowed(self::MAP[$hookCode]);
42 }
43 return true;
44 }
45
51 public static function isAllowed(string $code): bool
52 {
53 static $mapFlip = [];
54
55 if (!$mapFlip)
56 {
57 $mapFlip = array_flip(self::MAP);
58 }
59
60 if (
61 isset($mapFlip[$code]) &&
62 \Bitrix\Main\Loader::includeModule('bitrix24')
63 )
64 {
65 return Feature::isFeatureEnabled('landing_hook_' . $mapFlip[$code]);
66 }
67
68 return true;
69 }
70}
static isHookAllowed(string $hookCode)
Definition hook.php:36
static getRestrictionCodeByHookCode(string $hookCode)
Definition hook.php:25
static isAllowed(string $code)
Definition hook.php:51