Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
engine.php
1<?
8namespace Bitrix\Seo;
9
12
13class Engine
14{
15 const HTTP_STATUS_OK = 200;
19
20 protected $engineId = 'unknown engine';
21
22 protected $engine = null;
23 protected $engineSettings = array();
24
25 protected $authInterface = null;
26
27 public function __construct()
28 {
29 if(!$this->engine)
30 {
31 $this->engine = static::getEngine($this->engineId);
32 }
33
34 if(!is_array($this->engine))
35 {
36 throw new SystemException("Unknown search engine");
37 }
38 else
39 {
40 if($this->engine['SETTINGS'] <> '')
41 {
42 $this->engineSettings = unserialize($this->engine['SETTINGS'], ['allowed_classes' => false]);
43 }
44 }
45 }
46
47 public function getId()
48 {
49 return $this->engine['ID'];
50 }
51
52 public function getCode()
53 {
54 return $this->engine['CODE'];
55 }
56
57 public function getSettings()
58 {
59 return $this->engineSettings;
60 }
61
62 public function getClientId()
63 {
64 return $this->engine['CLIENT_ID'];
65 }
66
67 public function getClientSecret()
68 {
69 return $this->engine['CLIENT_SECRET'];
70 }
71
72 public function getAuthSettings()
73 {
74 return ($this->engineSettings['AUTH'] ?? false);
75 }
76
77 public function clearAuthSettings()
78 {
79 unset($this->engineSettings['AUTH']);
80 $this->saveSettings();
81 }
82
83 protected function saveSettings()
84 {
85 SearchEngineTable::update($this->engine['ID'], array(
86 'SETTINGS' => serialize($this->engineSettings)
87 ));
88 }
89
90 protected static function getEngine($engineId)
91 {
92 $dbEngine = SearchEngineTable::getByCode($engineId);
93 return $dbEngine->fetch();
94 }
95}
96
const HTTP_STATUS_OK
Definition engine.php:15
static getEngine($engineId)
Definition engine.php:90
const HTTP_STATUS_CREATED
Definition engine.php:16
const HTTP_STATUS_AUTHORIZATION
Definition engine.php:18
const HTTP_STATUS_NO_CONTENT
Definition engine.php:17