public function testAction(Request $request, $id) { // \Log::debug('123',['user'=>1]); // \Log::debug('1233',['user'=>12]); // \Log::debug('12asdasd33',['user'=>555]); // echo $id; // echo $request->query->get('token'); // echo $id; echo "<br>"; // \Cache::set('ha',123,60); // \Cache::redis() -> set('haa',123,60); // $config = \Config::getInstance(); // var_dump($config -> getConfig()); //echo \Session::get('aa','123'); // \Session::getFlashBag() -> setAll(['group', 'good']); // \Session::getFlashBag() -> all(); // $tube = 'testjob1'; // $data = '这是第一个队列任务'; // \Queue::put($tube, $data); $uri = $this->route()->getUri(); $uri = \Route::getUri(); $parameters = $this->route()->getParameters(); $parameters = \Route::getParameters(); $parametersName = $this->route()->getParametersName(); $action = $this->route()->getAction(); $methods = $this->route()->getMethods(); $currentMethod = $this->route()->getCurrentMethod(); $timezone = $this->getContainer()->getTimezone(); $environment = $this->getContainer()->getEnvironment(); $this->setFlashMessage('info', '消息提示!'); //return new JsonResponse([$id]); //var_dump($this->getGroupService()->getGroup(2)); return $this->render('Web/Views/Group/index.html.twig', array('uri' => $uri, 'parameters' => $parameters, 'parametersName' => $parametersName, 'action' => $action, 'methods' => $methods, 'currentMethod' => $currentMethod, 'timezone' => $timezone, 'environment' => $environment)); }
/** * map individual route Uri's * * @return mixed[object|void] */ function translateUri(Route $object) { //empty and move on if (empty($object)) { return $object; } //check for our special terms __HOME__, __404__ etc // the / states the start and end of the pattern // ^_{2} states the string must start with 2 underscores // ([a-zA-Z0-9])+ one or more alphanumeric // _{2}$ the string must end with 2 underscores // the / denotes the end of our string if (preg_match('/^_{2}([a-zA-Z0-9])+_{2}$/', $object->getUri(), $m)) { //if we find one, move on, __KEYWORDS__ are dealt with seperately $object->is_special = true; } $uri = $object->getUri(); //loop through our route map array and switch values in both uri and pattern strings foreach ($this->getRouteMap() as $key => $value) { //look for any matches within our uri if (stripos($uri, $key) !== false and $object->is_special === false) { //make our uri - if value is empty, add a slash to key to be removed $uri = str_ireplace($value ? $key : $key . '/', $value, $uri); } //look for any matches within our pattern if (stripos($pattern, $key) !== false) { //if we have a key called '{method}' and its empty, we're at the root level, so add 'index' $value = (in_array($key, array('{method}', '{submethod}')) and $value == '') ? 'index' : $value; //update our pattern variable $pattern = str_ireplace($key, $value, $pattern); } } //prepend the request type to the method, if we have a normal route if (strpos($pattern, '::') and $object->is_special === false) { //explode $pattern into $class and $method list($class, $method) = explode('::', $pattern); //put back together $pattern = $class . '::' . $this->request_type . '_' . $method; } //update the mapped pattern, keeping the original pattern $object->setMappedUri($uri); return $object; }
/** * @param Route $route * @param array $params * @return string */ protected function buildUrl(Route $route, array $params) { $targets = []; $replacements = []; foreach ($route->getVariableNames() as $key) { if (!isset($params[$key])) { throw new \InvalidArgumentException("Variable '{$key}' not found or null for route '{$route->getName()}'"); } $targets[] = ":" . $key; $replacements[] = $params[$key]; } return str_replace($targets, $replacements, $route->getUri()); }
/** */ public function testGetUri() { $this->assertEquals('/test/:name', $this->object->getUri()); }