Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
routingconfigurator.php
1<?php
9namespace Bitrix\Main\Routing;
10
12
36{
38 protected $router;
39
41 protected $scopeOptions;
42
46 public function __construct()
47 {
48 $this->scopeOptions = new Options;
49 }
50
51 public function __call($method, $arguments)
52 {
53 // setting option
54 if (in_array($method, Options::$optionList, true))
55 {
56 $configuration = $this->createConfiguration();
57 return $configuration->$method(...$arguments);
58 }
59
60 // setting route
61 if (in_array($method, RoutingConfiguration::$configurationList, true))
62 {
63 $configuration = $this->createConfiguration();
64 return $configuration->$method(...$arguments);
65 }
66
67 throw new SystemException(sprintf(
68 'Unknown method `%s` for object `%s`', $method, get_called_class()
69 ));
70 }
71
72 public function createConfiguration()
73 {
74 $configuration = new RoutingConfiguration;
75
76 $configuration->setConfigurator($this);
77 $this->router->registerConfiguration($configuration);
78
79 $configuration->setOptions(clone $this->scopeOptions);
80
81 return $configuration;
82 }
83
84 public function mergeOptionsWith($anotherOptions)
85 {
86 $this->scopeOptions->mergeWith($anotherOptions);
87 }
88
92 public function getRouter()
93 {
94 return $this->router;
95 }
96
100 public function setRouter($router)
101 {
102 $this->router = $router;
103 }
104
105 public function __clone()
106 {
107 $this->scopeOptions = clone $this->scopeOptions;
108 $this->scopeOptions->clearCurrent();
109 }
110}