1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
scope.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Rest\Engine\ActionFilter;
4
5
use Bitrix\Main\Error;
6
use Bitrix\Main\Event;
7
use Bitrix\Main\EventResult;
8
13
class
Scope
extends
Base
14
{
15
public
const
ERROR_INSUFFICIENT_SCOPE
=
'insufficient_scope'
;
16
17
private
$scopes;
18
19
public
function
__construct
(...$scopes)
20
{
21
$this->scopes = $scopes;
22
parent::__construct();
23
}
24
25
public
function
onBeforeAction
(
Event
$event
)
26
{
27
$scopeList = $this->
getCurrentScope
();
28
29
$need = array_diff($this->scopes, $scopeList);
30
31
if
(!$need)
32
{
33
return
null
;
34
}
35
36
$this->
addError
(
37
new
Error
(
38
'The current method required more scopes. ('
. implode(
', '
, $need) .
')'
,
39
self::ERROR_INSUFFICIENT_SCOPE
40
)
41
);
42
43
return
new
EventResult
(EventResult::ERROR,
null
,
null
, $this);
44
}
45
46
protected
function
getCurrentScope
()
47
{
48
$server = $this->
getRestServer
();
49
if
($server)
50
{
51
return
$server->getAuthScope();
52
}
53
54
return
[];
55
}
56
}
Bitrix\Main\Engine\ActionFilter\Base\addError
addError(Error $error)
Определения
base.php:80
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\EventResult
Определения
eventresult.php:5
Bitrix\Rest\Engine\ActionFilter\Base
Определения
base.php:13
Bitrix\Rest\Engine\ActionFilter\Base\getRestServer
getRestServer()
Определения
base.php:28
Bitrix\Rest\Engine\ActionFilter\Scope
Определения
scope.php:14
Bitrix\Rest\Engine\ActionFilter\Scope\ERROR_INSUFFICIENT_SCOPE
const ERROR_INSUFFICIENT_SCOPE
Определения
scope.php:15
Bitrix\Rest\Engine\ActionFilter\Scope\getCurrentScope
getCurrentScope()
Определения
scope.php:46
Bitrix\Rest\Engine\ActionFilter\Scope\onBeforeAction
onBeforeAction(Event $event)
Определения
scope.php:25
Bitrix\Rest\Engine\ActionFilter\Scope\__construct
__construct(... $scopes)
Определения
scope.php:19
Bitrix\Rest\Event
Определения
buffer.php:3
$event
$event
Определения
prolog_after.php:141
bitrix
modules
rest
lib
engine
actionfilter
scope.php
Создано системой
1.14.0