Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
filtercontrollerfactory.php
1
<?php
2
3
namespace
Bitrix\Main\Access\Filter\Factory
;
4
5
use
Bitrix\Main\Access\AccessibleController
;
6
use
Bitrix\Main\Access\Filter\AccessFilter
;
7
use
Bitrix\Main\Access\Filter\FilterFactory
;
8
use ReflectionClass;
9
10
class
FilterControllerFactory
implements
FilterFactory
11
{
12
protected
const
SUFFIX
=
'Filter'
;
13
14
public
function
createFromAction
(
string
$action,
AccessibleController
$controller): ?
AccessFilter
15
{
16
$className = $this->
getClassName
($action, $controller);
17
if
(!$className || !class_exists($className ))
18
{
19
return
null
;
20
}
21
22
$ref =
new
ReflectionClass($className);
23
if
($ref->implementsInterface(AccessFilter::class))
24
{
25
return
$ref->newInstance($controller);
26
}
27
28
return
null
;
29
}
30
31
protected
function
getClassName
(
string
$action,
AccessibleController
$controller): ?string
32
{
33
$action = explode(
'_'
, $action);
34
$action = array_map(fn($el) => ucfirst(mb_strtolower($el)), $action);
35
36
return
$this->
getNamespace
($controller) . implode($action) . static::SUFFIX;
37
}
38
39
protected
function
getNamespace
(
AccessibleController
$controller): string
40
{
41
$class = new \ReflectionClass($controller);
42
$namespace = $class->getNamespaceName();
43
44
return
$namespace.
'\\'
.static::SUFFIX.
'\\'
;
45
}
46
}
Bitrix\Main\Access\Filter\Factory\FilterControllerFactory
Definition
filtercontrollerfactory.php:11
Bitrix\Main\Access\Filter\Factory\FilterControllerFactory\SUFFIX
const SUFFIX
Definition
filtercontrollerfactory.php:12
Bitrix\Main\Access\Filter\Factory\FilterControllerFactory\createFromAction
createFromAction(string $action, AccessibleController $controller)
Definition
filtercontrollerfactory.php:14
Bitrix\Main\Access\Filter\Factory\FilterControllerFactory\getNamespace
getNamespace(AccessibleController $controller)
Definition
filtercontrollerfactory.php:39
Bitrix\Main\Access\Filter\Factory\FilterControllerFactory\getClassName
getClassName(string $action, AccessibleController $controller)
Definition
filtercontrollerfactory.php:31
Bitrix\Main\Access\AccessibleController
Definition
accessiblecontroller.php:15
Bitrix\Main\Access\Filter\AccessFilter
Definition
accessfilter.php:11
Bitrix\Main\Access\Filter\FilterFactory
Definition
filterfactory.php:11
Bitrix\Main\Access\Filter\Factory
Definition
filtercontrollerfactory.php:3
modules
main
lib
access
filter
factory
filtercontrollerfactory.php
Создано системой
1.10.0