1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
scope.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Main\Engine\ActionFilter;
4
5
use Bitrix\Main\ArgumentOutOfRangeException;
6
use Bitrix\Main\Engine\Controller;
7
use Bitrix\Main\Error;
8
use Bitrix\Main\Event;
9
use Bitrix\Main\EventResult;
10
11
class
Scope
extends
Base
12
{
13
public
const
AJAX
= 0b00000001;
14
public
const
REST
= 0b00000010;
15
public
const
CLI
= 0b00000100;
16
public
const
ALL
= 0b00000111;
17
18
public
const
NOT_AJAX
= self::ALL & ~self
::AJAX
;
19
public
const
NOT_REST
= self::ALL & ~self
::REST
;
20
public
const
NOT_CLI
= self::ALL & ~self
::CLI
;
21
22
private
$scopes;
23
24
public
function
__construct
($scopes)
25
{
26
$this->scopes = $scopes;
27
parent::__construct();
28
}
29
30
public
function
onBeforeAction
(
Event
$event
)
31
{
32
$scope = $this->
getCurrentScope
();
33
if
(($this->scopes & $scope) === $scope)
34
{
35
return
null
;
36
}
37
38
$this->
addError
(
new
Error
(
'Requested scope is invalid'
));
39
40
return
new
EventResult
(EventResult::ERROR,
null
,
null
, $this);
41
}
42
43
protected
function
getCurrentScope
()
44
{
45
switch
($this->
getAction
()->getController()->getScope())
46
{
47
case
Controller::SCOPE_AJAX:
48
return
static::AJAX;
49
case
Controller::SCOPE_REST:
50
return
static::REST;
51
case
Controller::SCOPE_CLI:
52
return
static::CLI;
53
}
54
55
throw
new
ArgumentOutOfRangeException
(
'Scope is invalid'
);
56
}
57
}
Bitrix\Main\ArgumentOutOfRangeException
Определения
ArgumentOutOfRangeException.php:9
Bitrix\Main\Engine\ActionFilter\Base
Определения
base.php:15
Bitrix\Main\Engine\ActionFilter\Base\addError
addError(Error $error)
Определения
base.php:80
Bitrix\Main\Engine\ActionFilter\Base\getAction
getAction()
Определения
base.php:48
Bitrix\Main\Engine\ActionFilter\Scope
Определения
scope.php:12
Bitrix\Main\Engine\ActionFilter\Scope\REST
const REST
Определения
scope.php:14
Bitrix\Main\Engine\ActionFilter\Scope\AJAX
const AJAX
Определения
scope.php:13
Bitrix\Main\Engine\ActionFilter\Scope\getCurrentScope
getCurrentScope()
Определения
scope.php:43
Bitrix\Main\Engine\ActionFilter\Scope\onBeforeAction
onBeforeAction(Event $event)
Определения
scope.php:30
Bitrix\Main\Engine\ActionFilter\Scope\NOT_AJAX
const NOT_AJAX
Определения
scope.php:18
Bitrix\Main\Engine\ActionFilter\Scope\ALL
const ALL
Определения
scope.php:16
Bitrix\Main\Engine\ActionFilter\Scope\__construct
__construct($scopes)
Определения
scope.php:24
Bitrix\Main\Engine\ActionFilter\Scope\NOT_REST
const NOT_REST
Определения
scope.php:19
Bitrix\Main\Engine\ActionFilter\Scope\CLI
const CLI
Определения
scope.php:15
Bitrix\Main\Engine\ActionFilter\Scope\NOT_CLI
const NOT_CLI
Определения
scope.php:20
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\Event
Определения
event.php:5
Bitrix\Main\EventResult
Определения
eventresult.php:5
$event
$event
Определения
prolog_after.php:141
bitrix
modules
main
lib
engine
actionfilter
scope.php
Создано системой
1.14.0