1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
routing_index.php
См. документацию.
1<?php
8
18
19require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/start.php");
20
22$application->initializeExtendedKernel(array(
23 "get" => $_GET,
24 "post" => $_POST,
25 "files" => $_FILES,
26 "cookie" => $_COOKIE,
27 "server" => $_SERVER,
28 "env" => $_ENV
29));
30
31$router = $application->getRouter();
32
33// match request
34$request = Context::getCurrent()->getRequest();
36
37if ($route !== null)
38{
39 $application->setCurrentRoute($route);
40
41 // copy route parameters to the request
42 if ($route->getParametersValues())
43 {
44 foreach ($route->getParametersValues()->getValues() as $name => $value)
45 {
46 $_GET[$name] = $value;
47 $_REQUEST[$name] = $value;
48 }
49 }
50
51 $_SERVER["REAL_FILE_PATH"] = '/bitrix/routing_index.php';
52 $controller = $route->getController();
53
54 if ($controller instanceof PublicPageController)
55 {
56 include_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/virtual_io.php");
58
59 $_SERVER["REAL_FILE_PATH"] = $controller->getPath();
60
61 include_once($io->GetPhysicalName($_SERVER['DOCUMENT_ROOT'].$controller->getPath()));
62 die;
63 }
64 elseif ($controller instanceof \Closure)
65 {
67
68 // pass current route
69 $binder->appendAutoWiredParameter(new Parameter(
70 Main\Routing\Route::class,
71 fn () => $route
72 ));
73
74 // pass request
75 $binder->appendAutoWiredParameter(new Parameter(
76 Main\HttpRequest::class,
77 fn () => Context::getCurrent()->getRequest()
78 ));
79
80 // pass named parameters
81 $binder->setSourcesParametersToMap([
82 $route->getParametersValues()->getValues()
83 ]);
84
85 // init kernel
86 require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
87
88 // call
89 $result = $binder->invoke();
90
91 // send response
92 if ($result !== null)
93 {
94 if ($result instanceof Main\HttpResponse)
95 {
96 // ready response
98 }
99 elseif (is_array($result))
100 {
101 // json
102 $response = new Json($result);
103 }
104 else
105 {
106 // string
107 $response = new Main\HttpResponse;
108 $response->setContent($result);
109 }
110
111 $application->getContext()->setResponse($response);
112 $response->send();
113 }
114
115 // terminate app
116 $application->terminate(0);
117 }
118 elseif (is_array($controller))
119 {
120 require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
121
122 // classic controller
123 [$controllerClass, $actionName] = $controller;
124 Loader::requireClass($controllerClass);
125
126 if (is_subclass_of($controllerClass, Main\Engine\Controller::class))
127 {
128 if (substr($actionName, -6) === 'Action')
129 {
130 $actionName = substr($actionName, 0, -6);
131 }
132
135 $app->runController($controllerClass, $actionName);
136 }
137 }
138 elseif (is_string($controller))
139 {
140 require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
141
142 // actually action could be attached to a few controllers
143 // but what if action was made for the one controller only
144 // then it could be used in routing
145 $actionClass = $controller;
146 Loader::requireClass($actionClass);
147
148 if (is_subclass_of($controller, Action::class))
149 {
150 if (is_subclass_of($actionClass, RoutableAction::class))
151 {
153 $controllerClass = $actionClass::getControllerClass();
154 $actionName = $actionClass::getDefaultName();
155
158 $app->runController($controllerClass, $actionName);
159 }
160 else
161 {
162 throw new SystemException(sprintf(
163 'Action `%s` should implement %s interface for being called in routing',
164 $actionClass, RoutableAction::class
165 ));
166 }
167 }
168 }
169
170 throw new SystemException(sprintf(
171 'Unknown controller `%s`', $controller
172 ));
173}
174
175require_once __DIR__.'/urlrewrite.php';
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
static getInstance()
Определения application.php:98
static buildForFunction($callable, $configuration=[])
Определения binder.php:48
Определения loader.php:13
static GetInstance()
Определения virtual_io.php:60
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
$result
Определения get_property_values.php:14
$app
Определения proxy.php:8
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
$io
Определения csv_new_run.php:98
$application
Определения bitrix.php:23
$name
Определения menu_edit.php:35
Определения culture.php:9
Определения action.php:3
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
die
Определения quickway.php:367
$router
Определения routing_index.php:31
$route
Определения routing_index.php:35
$response
Определения result.php:21