/** * Get the action for an "action" option. * * @param array|string $options * * @return string */ protected function getControllerAction($options) { if (is_array($options)) { return $this->url->action($options[0], array_slice($options, 1)); } return $this->url->action($options); }
/** * index. * * @param \Illuminate\Contracts\Foundation\Application $app * @param \Recca0120\Terminal\Kernel $kernel * @param \Illuminate\Http\Request $request * @param \Illuminate\Contracts\Response\Factory $responseFactory * @param \Illuminate\Contracts\Routing\UrlGenerator $urlGenerator * @param string $view * * @return mixed */ public function index(Application $app, Kernel $kernel, Request $request, ResponseFactory $responseFactory, UrlGenerator $urlGenerator, $view = 'index') { $kernel->call('--ansi'); $csrfToken = null; if ($request->hasSession() === true) { $csrfToken = $request->session()->token(); } $options = json_encode(['csrfToken' => $csrfToken, 'username' => 'LARAVEL', 'hostname' => php_uname('n'), 'os' => PHP_OS, 'basePath' => $app->basePath(), 'environment' => $app->environment(), 'version' => $app->version(), 'endpoint' => $urlGenerator->action('\\' . static::class . '@endpoint'), 'helpInfo' => $kernel->output(), 'interpreters' => ['mysql' => 'mysql', 'artisan tinker' => 'tinker', 'tinker' => 'tinker'], 'confirmToProceed' => ['artisan' => ['migrate', 'migrate:install', 'migrate:refresh', 'migrate:reset', 'migrate:rollback', 'db:seed']]]); $id = $view === 'panel' ? Str::random(30) : null; return $responseFactory->view('terminal::' . $view, compact('options', 'resources', 'id')); }
/** * Generates the menu item URL, using any of the following options, in order: * * If you pass a 'full_url' key within the item configuration, in that case * it will return it as the URL with no additional action. * * If you pass a 'url' key then it will call the Url::to method to complete * the base URL, you can also specify a 'secure' key to indicate whether * this URL should be secure or not. Otherwise the defaultSecure option will * be used. * * If you pass a 'route' key then it will call the getRouteAndParameters to * return the route's name and its parameters, then it will call Url::route * * If you pass an 'action' key it'd be processed in a similar way as the * route key, but calling the Url::action method instead. * * If none of these options are found then this function will simple return * a placeholder (#). * * * @param $values * @return mixed */ protected function generateUrl($values) { if (isset($values['full_url'])) { return $values['full_url']; } if (isset($values['url'])) { $isSecure = isset($values['secure']) ? $values['secure'] : $this->defaultSecure; return $this->url->to($values['url'], $isSecure); } if (isset($values['route'])) { list($route, $params) = $this->getRouteAndParameters($values['route']); return $this->url->route($route, $params); } if (isset($values['action'])) { list($route, $params) = $this->getRouteAndParameters($values['action']); return $this->url->action($route, $params); } return '#'; }
/** * Generate a HTML link to a controller action. * * @param string $action * @param string $title * @param array $parameters * @param array $attributes * * @return string */ public function linkAction($action, $title = null, $parameters = [], $attributes = []) { return $this->link($this->url->action($action, $parameters), $title, $attributes); }
/** * {@inheritdoc} */ public function action($action, $parameters = [], $absolute = true) { $permission = $this->securityApi->permissions()->getForAction($action); $this->checkPermission($permission); return $this->url->action($action, $parameters, $absolute); }
/** * Get the action for an "action" option. * * @param array|string $options * * @return string */ private function getControllerAction($options) { return is_array($options) ? $this->url->action($options[0], array_slice($options, 1)) : $this->url->action($options); }
/** * @param Route $route * @param UrlGenerator $urlGenerator * @param $queryString * @return bool */ private static function evaluateTemplated(Route $route, UrlGenerator $urlGenerator, $queryString) { // Does the route have named parameters? http://example.com/users/{users} if (count($route->parameterNames())) { return true; } $url = rawurldecode($urlGenerator->action($route->getActionName())); // Does the route's URI already contain a query string? http://example.com/users?page={page}&per_page={per_page} if (preg_match('/\\?.*=\\{.*?\\}/', $url)) { return true; } // Does the query string contain any parameters? if (preg_match('/\\?.*=\\{.*?\\}/', $queryString)) { return true; } return false; }
/** * Generate a HTML link to a controller action. * * @param string $action * @param string $title * @param array $parameters * @param array $attributes * @param bool $escaped * * @return \Illuminate\Support\HtmlString */ public function linkAction($action, $title = null, $parameters = [], $attributes = [], $escaped = true) { $url = $this->url->action($action, $parameters); return $this->link($url, $title, $attributes, null, $escaped); }