Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
toolsmanager.php
1<?php
2
4
5use Bitrix\Intranet\Settings\Tools;
7
8final class ToolsManager
9{
10 private static ?ToolsManager $instance = null;
11 private bool $canUseIntranetToolsManager;
12
13 private const AUTOMATION_TOOL_ID = 'automation';
14 private const BIZPROC_TOOL_ID = 'bizproc';
15 private const ROBOTS_TOOL_ID = 'robots';
16 private const SCRIPTS_TOOL_ID = 'bizproc_script';
17
18 public static function getInstance(): self
19 {
20 if (self::$instance === null)
21 {
22 self::$instance = new self();
23 }
24
25 return self::$instance;
26 }
27
28 public function __construct()
29 {
30 $this->canUseIntranetToolsManager = (
31 Loader::includeModule('intranet')
32 && class_exists(\Bitrix\Intranet\Settings\Tools\ToolsManager::class)
33 );
34 }
35
36 public function isAutomationAvailable(): bool
37 {
38 return $this->check(self::AUTOMATION_TOOL_ID);
39 }
40
41 public function isBizprocAvailable(): bool
42 {
43 return $this->check(self::BIZPROC_TOOL_ID) && $this->isAutomationAvailable();
44 }
45
46 public function isRobotsAvailable(): bool
47 {
48 return $this->check(self::ROBOTS_TOOL_ID) && $this->isAutomationAvailable();
49 }
50
51 public function isScriptsAvailable(): bool
52 {
53 return $this->check(self::SCRIPTS_TOOL_ID) && $this->isAutomationAvailable();
54 }
55
57 {
58 ob_start();
59 global $APPLICATION;
60 $APPLICATION->IncludeComponent(
61 'bitrix:intranet.tool.inaccessibility',
62 '',
63 [
64 'SLIDER_CODE' => 'limit_automation_off',
65 ],
66 );
67
68 return ob_get_clean();
69 }
70
71 private function check(string $toolId): bool
72 {
73 if ($this->canUseIntranetToolsManager)
74 {
75 return Tools\ToolsManager::getInstance()->checkAvailabilityByToolId($toolId);
76 }
77
78 return true;
79 }
80}