Ejemplo n.º 1
1
 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Illuminate\Routing\Route $route
  * @param  \Illuminate\Http\Request $request
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     if (is_null($route->getCompiled()->getHostRegex())) {
         return true;
     }
     return preg_match($route->getCompiled()->getHostRegex(), $request->getHost());
 }
Ejemplo n.º 2
0
function getControllerName()
{
    $route = new Route();
    print $route->getActionName();
    print "<br />";
    print $route->getAction();
}
Ejemplo n.º 3
0
 /**
  * Add the route to any look-up tables if necessary.
  *
  * @param  Route $route illuminate route
  *
  * @return void
  */
 protected function addLookups($route)
 {
     // If the route has a name, we will add it to the name look-up table so that we
     // will quickly be able to find any route associate with a name and not have
     // to iterate through every route every time we need to perform a look-up.
     $action = $route->getAction();
     if (isset($action['as'])) {
         if (isset($action['module'])) {
             $this->nameList[$action['module'] . "." . $action['as']] = $route;
         } else {
             $this->nameList[$action['as']] = $route;
         }
     }
     // When the route is routing to a controller we will also store the action that
     // is used by the route. This will let us reverse route to controllers while
     // processing a request and easily generate URLs to the given controllers.
     if (isset($action['controller'])) {
         $this->addToActionList($action, $route);
     }
     if (isset($action['module'])) {
         $this->addToModuleList($action, $route);
     }
     if (isset($action['settings_menu'])) {
         $this->addToSettingsMenuList($route);
     }
 }
Ejemplo n.º 4
0
 /**
  * @param RouteInstance $route
  */
 public function setRoute(RouteInstance $route)
 {
     // Compile route
     $request = new Request();
     $route->matches($request);
     $this->route = $route;
 }
 /**
  * Create a new Redirect response.
  *
  * @param RedirectInterface $redirect
  * @return \Illuminate\Http\RedirectResponse
  */
 public function create(RedirectInterface $redirect)
 {
     $parameters = array_merge(array_map(function () {
         return null;
     }, array_flip($this->route->parameterNames())), $this->route->parameters());
     return $this->redirector->to($this->parser->parse($redirect->getTo(), $parameters), $redirect->getStatus(), [], $redirect->isSecure());
 }
Ejemplo n.º 6
0
 /**
  * Validate a given rule against a route and request.
  *
  * @param BaseRoute $route
  * @param Request $request
  * @return bool
  */
 public function matches(BaseRoute $route, Request $request)
 {
     if (!$route instanceof Route) {
         return false;
     }
     return $route->getIntent() === (new Interpreter($request, $route->getWsdl()))->getIntent();
 }
Ejemplo n.º 7
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);
 }
Ejemplo n.º 8
0
 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @param  \Illuminate\Http\Request  $request
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     if (is_null($route->hostExpression())) {
         return true;
     }
     return preg_match($route->hostExpression(), $request->getHost());
 }
Ejemplo n.º 9
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이어야 합니다.');
 }
 protected function filterRouteAsClass(Route $route)
 {
     if ($this->option('name') && !str_contains($route->getName(), $this->option('name')) || $this->option('path') && !str_contains(implode('|', $route->methods()) . ' ' . $route->uri(), $this->option('path'))) {
         return null;
     }
     return $route;
 }
Ejemplo n.º 11
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $rules = $this->createRequest->rules();
     $rules['username'] .= ',username,' . $this->route->getParameter('users') . ',id';
     $rules['password'] = '******';
     return $rules;
 }
Ejemplo n.º 12
0
 public function find(Route $route)
 {
     $manuales = manuales::find($route->getParameter('manuales'));
     if (!$manuales) {
         abort(404);
     }
 }
Ejemplo n.º 13
0
 /**
  * Find the ObservationFormatUser or App Abort 404.
  */
 public function findObservationFormatUser(Route $route)
 {
     $this->observation = ObservationFormatUser::findOrFail($route->getParameter('doit'));
     $this->observation->load('answers.question');
     $this->observation->answers = $this->observation->answers->sortBy(function ($answer, $key) {
         return $answer->question->order;
     });
 }
Ejemplo n.º 14
0
 /**
  * Extracts the permission configured inside the route action array.
  *
  * @param Route $route
  * @return string|null
  */
 private function extractPermissionFrom(Route $route)
 {
     $parameters = $route->getAction();
     if (isset($parameters['permission'])) {
         return $parameters['permission'];
     }
     return null;
 }
Ejemplo n.º 15
0
 /**
  * Dispatch a request to a given controller and method.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @param  mixed  $controller
  * @param  string  $method
  * @return mixed
  */
 public function dispatch(Route $route, $controller, $method)
 {
     $parameters = $this->resolveClassMethodDependencies($route->parametersWithoutNulls(), $controller, $method);
     if (method_exists($controller, 'callAction')) {
         return $controller->callAction($method, $parameters);
     }
     return call_user_func_array([$controller, $method], $parameters);
 }
Ejemplo n.º 16
0
 /**
  * @param Route $route
  * @param CmfDbObject $object
  * @param array $conditions
  */
 protected function addParentIdsConditionsForDbObjectInjection(Route $route, CmfDbObject $object, array &$conditions)
 {
     foreach ($route->parameterNames() as $name) {
         if ($object->_hasField($name)) {
             $conditions[$name] = $route->parameter($name);
         }
     }
 }
 /**
  * Handle the command.
  *
  * @param RedirectRepositoryInterface $redirects
  * @param Redirector                  $redirector
  * @param Parser                      $parser
  * @param Route                       $route
  * @return \Illuminate\Http\RedirectResponse
  */
 public function handle(RedirectRepositoryInterface $redirects, Redirector $redirector, Parser $parser, Route $route)
 {
     $redirect = $redirects->find($this->id);
     $parameters = array_merge(array_map(function () {
         return null;
     }, array_flip($route->parameterNames())), $route->parameters());
     return $redirector->to($parser->parse($redirect->getTo(), $parameters), $redirect->getStatus(), [], $redirect->isSecure());
 }
Ejemplo n.º 18
0
 /**
  * Find the Checklist or App Abort 404.
  */
 public function findChecklist(Route $route)
 {
     $this->checklist = Checklist::findOrFail($route->getParameter('doit'));
     $this->checklist->load('answers.question');
     $this->checklist->answers = $this->checklist->answers->sortBy(function ($answer, $key) {
         return $answer->question->order;
     });
 }
Ejemplo n.º 19
0
 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');
     }
 }
Ejemplo n.º 20
0
 /**
  * Validates show path.
  * @param Route $route
  * @return Response
  */
 public function validateShowPath(Route $route)
 {
     $org = $route->getParameter('organisations');
     $attr = $route->getParameter('attrs');
     if ($attr->organisation_id !== $org->id) {
         return Response::json(null, 404);
     }
 }
Ejemplo n.º 21
0
 /**
  * Add the given route to the arrays of routes.
  *
  * @param  \Illuminate\Routing\Route $route
  * @return void
  */
 protected function addToCollections($route)
 {
     $domainAndUri = $route->domain() . $route->getUri() . $route->getPriority();
     foreach ($route->methods() as $method) {
         $this->routes[$method][$domainAndUri] = $route;
     }
     $this->allRoutes[$method . $domainAndUri] = $route;
 }
 /**
  * Get all of the pattern filters matching the route.
  *
  * @param  \Illuminate\Routing\Route $route
  * @return array
  */
 protected function getPatternFilters($route)
 {
     $patterns = array();
     foreach ($route->getMethods() as $method) {
         $inner = $this->router->findPatternFilters($method, $route->getPath());
         $patterns = array_merge($patterns, $inner);
     }
     return $patterns;
 }
Ejemplo n.º 23
0
 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Illuminate\Routing\Route $route
  * @param  \Illuminate\Http\Request $request
  *
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     $regex = $route->getCompiled()->getRegex();
     if (str_contains($request->getRequestUri(), '/wp-admin')) {
         return preg_match(str_replace('$#s', '(?:&.+)?$#s', $regex), rawurldecode($request->getRequestUri()));
     }
     $path = $request->path() == '/' ? '/' : '/' . $request->path();
     return preg_match($regex, rawurldecode($path));
 }
Ejemplo n.º 24
0
 public function rules(Route $route)
 {
     if ($route->getName() == 'backend.backend.users.update') {
         $rules = ['user.email' => 'required|unique:backend_users,email,' . $route->parameter('id'), 'user.active' => 'required', 'groups' => 'required'];
     } else {
         $rules = ['user.email' => 'required|unique:backend_users,email', 'user.active' => 'required', 'groups' => 'required', 'password' => 'required'];
     }
     return $rules;
 }
Ejemplo n.º 25
0
 /**
  * Validate a given rule against a route and request.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @param  \Illuminate\Http\Request  $request
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     if ($route->httpOnly()) {
         return !$request->secure();
     } elseif ($route->secure()) {
         return $request->secure();
     }
     return true;
 }
Ejemplo n.º 26
0
 public function resize(Route $route)
 {
     /**
      * @var $media MediaModel
      */
     $media = MediaModel::query()->find($route->parameter('id'));
     $path = storage_path('app/' . $media->path());
     $url = $media->url($route->parameter('width'), $route->parameter('height'), $route->parameter('type'));
     $filename = public_path($url);
     is_file($filename) && unlink($filename);
     $width = $route->parameter('width') == '-' ? null : $route->parameter('width');
     $height = $route->parameter('height') == '-' ? null : $route->parameter('height');
     $img = \Image::make($path);
     $aspectRatio = $img->width() / $img->height();
     $nwidth = $width;
     $nheight = $height;
     switch ($route->parameter('type')) {
         case 'c':
             if ($width !== null || $height !== null) {
                 if ($width === null) {
                     $aspect = intval($height * $aspectRatio) / $height;
                     $nwidth = $img->width();
                 } else {
                     if ($height === null) {
                         $aspect = $width / intval($width / $aspectRatio);
                         $nheight = $img->height();
                     } else {
                         $aspect = $width / $height;
                     }
                 }
                 if ($width !== null && $height !== null) {
                     if ($aspect < $aspectRatio) {
                         $img->resize(null, $height, function ($constraint) {
                             $constraint->aspectRatio();
                         });
                     } else {
                         $img->resize($width, null, function ($constraint) {
                             $constraint->aspectRatio();
                         });
                     }
                 }
                 $img->crop($nwidth, $nheight);
             }
             break;
         case 'r':
             if ($width !== null || $height !== null) {
                 $img->resize($width, $height, function ($constraint) {
                     $constraint->aspectRatio();
                 });
             }
             break;
     }
     \File::makeDirectory(dirname($filename), 0777, true, true);
     $img->save($filename, 80);
     return \Redirect::to($url);
 }
Ejemplo n.º 27
0
 /**
  * Add the necessary where clauses to the route based on its initial registration.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @return \Illuminate\Routing\Route
  */
 protected function addWhereClausesToRoute($route)
 {
     foreach ($this->get_patterns_defaults() as $key => $value) {
         $route->defaults($key, $value);
     }
     if ($route->getName() == 'page') {
         #dd($route);
     }
     parent::addWhereClausesToRoute($route);
 }
Ejemplo n.º 28
0
 /**
  * Validate a given rule against a route and request.
  *
  * @param  LaravelRoute   $route   illuminate route
  * @param  LaravelRequest $request illuminate request
  *
  * @return bool
  */
 public function matches(Route $route, Request $request)
 {
     $path = $request->path() == '/' ? '/' : '/' . $request->path();
     $firstSegment = $request->segment(1);
     if ($firstSegment === null) {
         return true;
     } else {
         return preg_match($route->getCompiled()->getRegex(), rawurldecode($path));
     }
 }
Ejemplo n.º 29
0
 public function find(Route $route)
 {
     if ($route->getParameter('inventario')) {
         $codigo = $route->getParameter('inventario');
     } else {
         $codigo = $route->getParameter('id');
     }
     $this->datos = Inventario::find($codigo);
     $this->notFound($this->datos);
 }
Ejemplo n.º 30
0
 public function __construct(Container $container, Route $route)
 {
     $this->container = $container;
     $opts = $route->getAction();
     $method = array_get($opts, self::ROUTE_ACTION_KEY, 'getDefaultMeta');
     if (!is_callable([$this, $method])) {
         $method = 'getDefaultMeta';
     }
     $this->method = $method;
 }