/** * Sends a http-query. * @param string $url * @param array $params * @return null|\rock\response\Response * @throws RouteException * @throws \rock\helpers\InstanceException */ public function send($url, array $params = []) { $route = $this->route; /** @var Route $route */ $route = Instance::ensure(['class' => $route::className(), 'request' => $this->getRequest($url, $params)]); if (!empty($this->route->groups)) { $check = $route->checkGroups($this->route->getRawGroups()); } else { $check = $route->checkRules($this->route->getRawRules()); } if ($check) { return $route->response; } return null; }
<?php use rock\base\Alias; use rock\db\BatchQueryResult; use rock\rbac\Permission; use rock\rbac\Role; use rock\Rock; use rock\security\Security; use rock\template\Template; return array_merge(['route' => ['class' => \rock\route\Route::className()], 'access' => ['class' => \rock\access\Access::className()], 'behavior' => ['class' => \rock\components\Behavior::className()], 'db' => ['class' => \rock\db\Connection::className(), 'username' => 'root', 'password' => 'root', 'charset' => 'utf8', 'dsn' => 'mysql:host=localhost;dbname=rockdemo;charset=utf8', 'tablePrefix' => 'spt_', 'aliasSeparator' => '__'], 'BatchQueryResult' => ['class' => BatchQueryResult::className()], 'template' => ['class' => Template::className(), 'locale' => [\rock\LocaleProperties::className(), 'locale'], 'autoEscape' => Template::ESCAPE | Template::TO_TYPE, 'handlerLink' => function ($link, Template $template, array $params = []) { if (!($link = Alias::getAlias("@{$link}", [], false))) { return '#'; } return $template->autoEscape(\rock\template\filters\BaseFilter::modifyUrl($link, $params)); }, 'extensions' => ['cfg' => function (array $keys) { return \rock\helpers\ArrayHelper::getValue(Rock::$config, $keys); }, 'user' => function (array $keys) { if (current($keys) === 'isGuest') { return Rock::$app->user->isGuest(); } elseif (in_array(current($keys), ['isLogged', 'isAuthenticated'], true)) { return !Rock::$app->user->isGuest(); } return \rock\helpers\ArrayHelper::getValue(Rock::$app->user->getAll(), $keys); }, 'call' => function (array $call, array $params = [], Template $template) { if (!isset($call[1])) { $call[1] = null; } list($class, $method) = $call; if ($class === 'context') { $object = $template->context; $function = [$object, $method];
<?php use rock\route\Route; return ['route' => ['class' => \rock\route\Route::className(), 'rules' => [[\rock\route\Route::GET, [Route::FILTER_GET => ['service' => 'logout']], [\apps\frontend\controllers\LogoutController::className(), 'actionLogout']], [rock\route\Route::GET, '/', [\apps\frontend\controllers\MainController::className(), 'actionIndex']], [[rock\route\Route::GET, \rock\route\Route::POST], '/signin.html', [\apps\frontend\controllers\SigninController::className(), 'actionSignin']], [[rock\route\Route::GET, \rock\route\Route::POST], '/signup.html', [\apps\frontend\controllers\SignupController::className(), 'actionSignup']], [[rock\route\Route::GET, \rock\route\Route::POST], '/recovery.html', [\apps\frontend\controllers\RecoveryController::className(), 'activeRecovery']], [\rock\route\Route::GET, '/activation.html', [\apps\frontend\controllers\ActivationController::className(), 'actionIndex']], [\rock\route\Route::GET, '*', [\apps\frontend\controllers\MainController::className(), 'notPage']]]], 'template' => ['head' => [\apps\frontend\configs\TemplateProperties::className(), 'head'], 'cssFiles' => [rock\template\Template::POS_HEAD => ['<link href="/assets/css/demo.min.css" rel="stylesheet"/>']], 'jsFiles' => [rock\template\Template::POS_END => ['<!--[if !(IE) | (gt IE 8) ]>-->', '<script src="/assets/js/app.min.js"></script>', '<![endif]-->']]]];