本文整理汇总了PHP中Container::getRouter方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::getRouter方法的具体用法?PHP Container::getRouter怎么用?PHP Container::getRouter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Container
的用法示例。
在下文中一共展示了Container::getRouter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
if (!in_array(App::ROUTER_NO_DISPATCH, $this->options, true)) {
$this->container->getRouter()->dispatch($this->container->getRequest(), $this->container->getResponse());
}
}
示例2: api_get_languages
$languages = api_get_languages();
$ajaxPath = api_get_path(WEB_CODE_PATH) . 'inc/ajax/events.ajax.php';
$action_array = array(array('url' => 'event_controller.php?action=listing', 'content' => Display::return_icon('view_text.png', get_lang('ListView'), array(), ICON_SIZE_MEDIUM)));
$key_lang = get_lang('YouHaveSomeUnsavedChanges');
$users = UserManager::get_user_list(array(), array('firstname'));
$new_user_list = array();
foreach ($users as $user) {
if ($user['status'] == ANONYMOUS) {
continue;
}
$new_user_list[] = $user;
}
/**
* Header definition
*/
$interbreadcrumb[] = array('url' => Container::getRouter()->generate('administration'), 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'event_controller.php', 'name' => get_lang('Events'));
$tool_name = get_lang('EventMessageManagement');
Display::display_header($tool_name);
echo Display::actions($action_array);
/**
* JavaScript code
* @todo move into HTML header
*/
?>
<script>
var usersList = <?php
echo json_encode($new_user_list);
?>
;
var eventTypes = <?php
示例3: Container
<?php
use Bravicility\Failure\FailureHandler;
use Bravicility\Http\Request;
use Bravicility\Http\Response\Response;
use Bravicility\Http\Response\TextResponse;
use Bravicility\Router\RouteNotFoundException;
require_once __DIR__ . '/../vendor/autoload.php';
$container = new Container();
$logger = $container->getErrorLogger();
FailureHandler::setup(function ($error) use($logger) {
(new TextResponse(500, 'Произошла ошибка сервера'))->send();
$logger->error($error['message'], $error);
exit;
});
try {
$request = Request::createFromGlobals();
$route = $container->getRouter()->route($request->getMethod(), $request->getUrlPath());
$request->setOptions($route->vars);
/** @var Response $response */
$response = (new $route->class($container))->{$route->method}($request);
} catch (RouteNotFoundException $e) {
$response = new Response(404);
} catch (BadRequestException $e) {
$response = new Response(400, $e->getMessage());
}
$response->addHeader('Access-Control-Allow-Origin: *');
$response->send();