コード例 #1
0
 /**
  * 메뉴의 링크를 생성하여 반환한다. 메뉴에 link정보가 있을 경우 link정보를 우선 사용하여 생성한다.
  * 그 다음으로 메뉴에 연결된 route정보를 사용하여 링크를 생성한다.
  *
  * @return Route|mixed|string
  * @throws \Exception
  */
 public function link()
 {
     if ($this->display === false) {
         return '#';
     }
     // menu에 링크 정보가 있을 경우
     if ($this->link !== null) {
         if ($this->link instanceof Closure) {
             return $this->link();
         } else {
             return $this->link;
         }
     }
     // 어떤 링크정보도 찾을 수 없으면 #
     if ($this->route === null) {
         return '#';
     }
     // route 정보 사용
     if ($name = $this->route->getName()) {
         return route($name);
     } elseif ($action = $this->route->getActionName()) {
         if ($action !== 'Closure') {
             return action($action);
         }
     }
     throw new LinkNotFoundException('admin 메뉴가 지정된 route는 name(as)이 지정되어 있거나 Controller action이어야 합니다.');
 }
コード例 #2
0
ファイル: PermissionMiddleware.php プロジェクト: Houbsi/Core
 /**
  * @param Request  $request
  * @param callable $next
  * @return mixed
  */
 public function handle(Request $request, \Closure $next)
 {
     $action = $this->route->getActionName();
     $actionMethod = substr($action, strpos($action, "@") + 1);
     $segmentPosition = $this->getSegmentPosition($request);
     $moduleName = $this->getModuleName($request, $segmentPosition);
     $entityName = $this->getEntityName($request, $segmentPosition);
     $permission = $this->getPermission($moduleName, $entityName, $actionMethod);
     if (!$this->auth->hasAccess($permission)) {
         Flash::error(trans('core::core.permission denied', ['permission' => $permission]));
         return Redirect::back();
     }
     return $next($request);
 }
コード例 #3
0
ファイル: Collection.php プロジェクト: jeylabs/jsroute
 /**
  * Get the route information for a given route.
  *
  * @param $route \Illuminate\Routing\Route
  * @param $filter string
  * @param $namespace string
  *
  * @return array
  */
 protected function getRouteInformation(Route $route, $filter, $namespace)
 {
     $host = $route->domain();
     $methods = $route->getMethods();
     $uri = $route->uri();
     $name = $route->getName();
     $action = $route->getActionName();
     $jsroute = array_get($route->getAction(), 'jsroute', null);
     if (!empty($namespace)) {
         $a = $route->getAction();
         if (isset($a['controller'])) {
             $action = str_replace($namespace . '\\', '', $action);
         }
     }
     switch ($filter) {
         case 'all':
             if ($jsroute === false) {
                 return null;
             }
             break;
         case 'only':
             if ($jsroute !== true) {
                 return null;
             }
             break;
     }
     return compact('host', 'methods', 'uri', 'name', 'action');
 }
コード例 #4
0
 public function __construct(Route $route)
 {
     $this->middleware(function ($request, $next) {
         // if session is not set get it from .env SHOP_CODE
         if (!$request->session()->has('shop')) {
             $shop = Shop::where('code', config('app.shop_code'))->first();
             $request->session()->put('shop', $shop->id);
         }
         // if limit is not set default pagination limit
         if (!$request->session()->has('limit')) {
             $request->session()->put('limit', 100);
         }
         // if session is not set reset the session for the language
         if (!$request->session()->has('language')) {
             $request->session()->put('language', config('app.locale'));
         }
         // if session is not set reset the session for the basket
         if (!$request->session()->has('basket')) {
             $request->session()->put('basket', ['subtotal' => 0, 'count' => 0, 'items' => []]);
         }
         // global list of categories
         $categories = Category::where('shop_id', $request->session()->get('shop'))->orderBy('order', 'asc')->get();
         // share globals
         view()->share('language', $request->session()->get('language'));
         view()->share('categories', $categories);
         return $next($request);
     });
     // add controller & action to the body class
     $currentAction = $route->getActionName();
     list($controller, $method) = explode('@', $currentAction);
     $controller = preg_replace('/.*\\\\/', '', $controller);
     $action = preg_replace('/.*\\\\/', '', $method);
     view()->share('body_class', $controller . '-' . $action);
 }
コード例 #5
0
 /**
  * 메뉴의 링크를 생성하여 반환한다. 메뉴에 link정보가 있을 경우 link정보를 우선 사용하여 생성한다.
  * 그 다음으로 메뉴에 연결된 route정보를 사용하여 링크를 생성한다.
  *
  * @return Route|mixed|string
  * @throws \Exception
  */
 public function link()
 {
     if ($this->display === false) {
         return null;
     }
     // menu에 링크 정보가 있을 경우
     if ($this->link !== null) {
         if ($this->link instanceof Closure) {
             return $this->link();
         } else {
             return $this->link;
         }
     }
     // 어떤 링크정보도 찾을 수 없으면 #
     if ($this->route === null) {
         return null;
     }
     // route 정보 사용
     if ($name = $this->route->getName()) {
         return route($name);
     } elseif ($action = $this->route->getActionName()) {
         if ($action !== 'Closure') {
             return action($action);
         }
     }
     throw new LinkNotFoundException();
 }
コード例 #6
0
function getControllerName()
{
    $route = new Route();
    print $route->getActionName();
    print "<br />";
    print $route->getAction();
}
コード例 #7
0
ファイル: BaseController.php プロジェクト: ksp-media/laikacms
 public function auth(\Illuminate\Routing\Route $route, $request)
 {
     $action = explode('@', $route->getActionName());
     $whiteList = ['showLogin', 'loginAction', 'logoutAction'];
     if (\Session::get('cmslogin') == null && !in_array($action[1], $whiteList)) {
         return \Redirect::to('/' . _LCMS_PREFIX_ . '/login');
     }
 }
コード例 #8
0
ファイル: Active.php プロジェクト: yinniermei/active
 /**
  * Update the route and request instances
  *
  * @param Route   $route
  * @param Request $request
  */
 public function updateInstances($route, $request)
 {
     $this->request = $request;
     if ($request) {
         $this->uri = urldecode($request->path());
     }
     $this->route = $route;
     if ($route) {
         $this->action = $route->getActionName();
         $actionSegments = Str::parseCallback($this->action, null);
         $this->controller = head($actionSegments);
         $this->method = last($actionSegments);
     }
 }
コード例 #9
0
 /**
  * Get the route information for a given route.
  *
  * @param \Illuminate\Routing\Route $route        	
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     return $this->filterRoute(['host' => $route->domain(), 'method' => implode('|', $route->methods()), 'uri' => $route->uri(), 'name' => $route->getName(), 'action' => $route->getActionName(), 'middleware' => $this->getMiddleware($route)]);
 }
コード例 #10
0
 /**
  * Get before filters.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @return string
  */
 protected function getMiddleware($route)
 {
     $middlewares = array_values($route->middleware());
     $actionName = $route->getActionName();
     if (!empty($actionName) && $actionName !== 'Closure') {
         $middlewares = array_merge($middlewares, $this->getControllerMiddleware($actionName));
     }
     return implode(',', $middlewares);
 }
コード例 #11
0
ファイル: ApiDocsGenerator.php プロジェクト: f2m2/apidocs
 /**
  * Get the route information for a given route.
  *
  * @param  string  $name
  * @param  \Illuminate\Routing\Route  $route
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     $uri = implode('|', $route->methods()) . ' ' . $route->uri();
     return $this->filterRoute(array('host' => $route->domain(), 'uri' => $uri, 'name' => $route->getName(), 'action' => $route->getActionName(), 'prefix' => $route->getPrefix(), 'method' => $route->methods()[0]));
 }
コード例 #12
0
ファイル: RouteList.php プロジェクト: aginev/acl
 /**
  * Get the route information for a given route.
  *
  * @param  \Illuminate\Routing\Route $route
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     list($controller, $action) = explode("@", $route->getActionName());
     return ['host' => $route->domain(), 'method' => implode('|', $route->methods()), 'uri' => $route->uri(), 'name' => $route->getName(), 'controller' => $controller, 'action' => $action, 'resource' => $route->getActionName(), 'middleware' => Collection::make($this->getMiddleware($route))];
 }
コード例 #13
0
 /**
  * @param Route $route
  *
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     return ['method' => implode('|', $route->methods()), 'uri' => $route->uri(), 'name' => $route->getName(), 'action' => $route->getActionName()];
 }
コード例 #14
0
 /**
  * @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;
 }
コード例 #15
0
 protected function getRouteInformation(Route $route, $current)
 {
     $uri = implode(' | ', $route->methods()) . ' <a href="' . $this->url->to($route->uri()) . '">' . $route->uri() . '</a>';
     return array('current' => $current == $route, 'host' => $route->domain(), 'uri' => $uri, 'name' => $route->getName(), 'action' => $route->getActionName(), 'before' => $this->getBeforeFilters($route), 'after' => $this->getAfterFilters($route));
 }
コード例 #16
0
ファイル: RouteHelper.php プロジェクト: jarischaefer/hal-api
 /**
  * Checks if a route is bound to an implementation of {@see HalApiControllerContract}
  *
  * @param Route $route
  * @return bool
  */
 public static function isValid(Route $route)
 {
     $actionName = $route->getActionName();
     // valid routes are backed by a controller (e.g. App\Http\Controllers\MyController@doSomething)
     if (!str_contains($actionName, '@')) {
         return false;
     }
     $class = explode('@', $actionName)[0];
     // only add a link if this class is its controller's parent
     if (!is_subclass_of($class, HalApiControllerContract::class)) {
         return false;
     }
     return true;
 }
コード例 #17
0
ファイル: RouteScanner.php プロジェクト: leitom/role
 /**
  * Get the route information for a given route.
  *
  * @param  string  $name
  * @param  \Symfony\Component\Routing\Route  $route
  * @return array
  */
 protected function getRouteInformation($name, Route $route)
 {
     $uri = head($route->methods()) . ' ' . $route->uri();
     return array('host' => (string) $route->domain(), 'method' => (string) $this->getMethod($uri), 'uri' => (string) $uri, 'name' => (string) $route->getName(), 'action' => (string) $route->getActionName(), 'before' => (string) $this->getBeforeFilters($route), 'after' => (string) $this->getAfterFilters($route));
 }
コード例 #18
0
ファイル: ApiRoutesCommand.php プロジェクト: andymrussell/api
 /**
  * Get the route information for a given route.
  *
  * @param \Illuminate\Routing\Route $route
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     return $this->filterRoute(array('host' => $route->domain(), 'uri' => implode('|', $route->methods()) . ' ' . $route->uri(), 'name' => $route->getName(), 'action' => $route->getActionName(), 'version' => implode(', ', array_get($route->getAction(), 'version')), 'protected' => array_get($route->getAction(), 'protected') ? 'Yes' : 'No', 'scopes' => $this->getScopes($route)));
 }
コード例 #19
0
ファイル: RoutesCommand.php プロジェクト: mawaha/tracker
 /**
  * Get the route information for a given route.
  *
  * @param  string  $name
  * @param  \Illuminate\Routing\Route  $route
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     $uri = implode('|', $route->methods()) . ' ' . $route->uri();
     return $this->filterRoute(array('host' => $route->domain(), 'uri' => $uri, 'name' => $route->getName(), 'action' => $route->getActionName(), 'before' => $this->getBeforeFilters($route), 'after' => $this->getAfterFilters($route)));
 }
コード例 #20
0
 /**
  * Get the route information for a given route.
  *
  * @param  \Illuminate\Routing\Route $route
  * @return array
  */
 protected function getRouteInformation(Route $route)
 {
     return $this->filterRoute(['uri' => $route->uri(), 'methods' => $route->methods(), 'name' => $route->getName(), 'action' => $route->getActionName()]);
 }