Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
businessauthadapter.php
1<?php
2
4
5use Bitrix\Seo;
12use InvalidArgumentException;
13
15{
17 private $setup;
18
20 private $config;
21
23 private $installs;
24
25 public function getAuthUrl()
26 {
27 if(!Seo\Service::isRegistered())
28 {
29 Seo\Service::register();
30 }
31 $authorizeUrl = Seo\Service::getAuthorizeLink();
32 $authorizeData = Seo\Service::getAuthorizeData(
33 $this->getEngineCode(),
34 $this->canUseMultipleClients() ? Seo\Service::CLIENT_TYPE_MULTIPLE : Seo\Service::CLIENT_TYPE_SINGLE
35 );
36 $uri = new Uri($authorizeUrl);
37 if(!empty($this->parameters['URL_PARAMETERS']))
38 {
39 $authorizeData['urlParameters'] = $this->parameters['URL_PARAMETERS'];
40 }
41 if($this->setup && $this->config)
42 {
43 $authorizeData['settings'] = Json::encode([
44 'setup' => $this->setup->toArray() + ($this->installs? $this->installs->toArray() : []),
45 'business_config' => $this->config->toArray(),
46 'repeat' => false
47 ]);
48 }
49
50 $uri->addParams($authorizeData);
51 return $uri->getLocator();
52 }
53
59 public function setSetup(IAuthSettings $setup = null): self
60 {
61 if($setup instanceof Facebook\Setup)
62 {
63 $this->setup = $setup;
64 return $this;
65 }
66 throw new InvalidArgumentException("Argument is not instance of Facebook/Setup");
67 }
68
74 public function setConfig(IAuthSettings $config = null): self
75 {
76 if($config instanceof Facebook\Config)
77 {
78 $this->config = $config;
79 return $this;
80 }
81 throw new InvalidArgumentException("Argument is not instance of Facebook/Config");
82 }
83
84 public function setInstalls(?IAuthSettings $installs) : self
85 {
86 if($installs instanceof Facebook\Installs)
87 {
88 $this->installs = $installs;
89 return $this;
90 }
91 throw new InvalidArgumentException("Argument is not instance of Facebook/Installs");
92 }
93}
static isRegistered()
Definition service.php:59
const CLIENT_TYPE_MULTIPLE
Definition service.php:48