1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
closurewrapper.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Main\Engine\ActionFilter;
4
5
6
use Bitrix\Main\Application;
7
use Bitrix\Main\Config\Configuration;
8
use Bitrix\Main\Event;
9
use Bitrix\Main\InvalidOperationException;
10
use Closure;
11
12
final
class
ClosureWrapper
extends
Base
13
{
17
private
$closure;
18
23
public
function
__construct
(Closure $closure)
24
{
25
$this->closure = $closure->bindTo($this, $this);
26
parent::__construct();
27
}
28
32
public
function
onBeforeAction
(
Event
$event
)
33
{
34
$this->ensureClosure();
35
36
return \call_user_func($this->closure,
$event
);
37
}
38
42
public
function
onAfterAction
(
Event
$event
)
43
{
44
$this->ensureClosure();
45
46
return \call_user_func($this->closure,
$event
);
47
}
48
49
private
function
ensureClosure(): void
50
{
51
if
($this->closure ===
null
)
52
{
53
$exception =
new
InvalidOperationException
(
'Closure has "static" modifier and can\'t be used. Use non-static closure instead.'
);
54
55
$exceptionHandling = Configuration::getValue(
'exception_handling'
);
56
if
(!empty($exceptionHandling[
'debug'
]))
57
{
58
Application::getInstance
()->getExceptionHandler()->writeToLog($exception);
59
}
60
61
throw
$exception;
62
}
63
}
64
}
Bitrix\Main\Application\getInstance
static getInstance()
Определения
application.php:98
Bitrix\Main\Engine\ActionFilter\Base
Определения
base.php:15
Bitrix\Main\Engine\ActionFilter\ClosureWrapper
Определения
closurewrapper.php:13
Bitrix\Main\Engine\ActionFilter\ClosureWrapper\onAfterAction
onAfterAction(Event $event)
Определения
closurewrapper.php:42
Bitrix\Main\Engine\ActionFilter\ClosureWrapper\__construct
__construct(Closure $closure)
Определения
closurewrapper.php:23
Bitrix\Main\Engine\ActionFilter\ClosureWrapper\onBeforeAction
onBeforeAction(Event $event)
Определения
closurewrapper.php:32
Bitrix\Main\Event
Определения
event.php:5
Bitrix\Main\InvalidOperationException
Определения
InvalidOperationException.php:9
$event
$event
Определения
prolog_after.php:141
bitrix
modules
main
lib
engine
actionfilter
closurewrapper.php
Создано системой
1.14.0