当前位置: 首页>>代码示例>>PHP>>正文


PHP Router::macro方法代码示例

本文整理汇总了PHP中Illuminate\Routing\Router::macro方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::macro方法的具体用法?PHP Router::macro怎么用?PHP Router::macro使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Routing\Router的用法示例。


在下文中一共展示了Router::macro方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: registerMacros

 protected function registerMacros(Router $router)
 {
     $router->macro('module', function ($module, $sortable = false) use($router) {
         $controller = ucfirst($module) . 'Controller';
         if ($sortable) {
             $router->patch("{$module}/changeOrder", $controller . '@changeOrder');
         }
         $router->resource($module, $controller);
     });
     $this->app['paginateroute']->registerMacros();
 }
开发者ID:spatie-custom,项目名称:blender,代码行数:11,代码来源:RouteServiceProvider.php

示例2: enableGenericResourceRouting

 /**
  * Set up the generic resource routes + controller.
  *
  * @param Router $router
  * @return void
  */
 protected function enableGenericResourceRouting(Router $router)
 {
     $app = $this->app;
     $app->bind('eloquentjs.router', RouteRegistrar::class);
     $app->when(RouteRegistrar::class)->needs('$controller')->give(GenericController::class);
     $app->when(GenericController::class)->needs(Model::class)->give(function ($app) {
         if ($resource = $app['eloquentjs.router']->getCurrentResource()) {
             return $app->make($resource);
         }
     });
     $router->macro('eloquent', function ($uri, $resource, $options = []) use($app) {
         $app['eloquentjs.router']->addRoute($uri, $resource, $options);
     });
 }
开发者ID:parsnick,项目名称:eloquentjs,代码行数:20,代码来源:EloquentJsServiceProvider.php

示例3: macro

 /**
  * Register a custom macro.
  *
  * @param string $name
  * @param callable $macro
  * @return void 
  * @static 
  */
 public static function macro($name, $macro)
 {
     \Illuminate\Routing\Router::macro($name, $macro);
 }
开发者ID:satriashp,项目名称:tour,代码行数:12,代码来源:_ide_helper.php

示例4: registerMacros

 /**
  * @param \Illuminate\Routing\Router $router
  */
 protected function registerMacros(Router $router)
 {
     $router->macro('redirect', function ($url, $action) use($router) {
         $router->get($url, function () use($action) {
             return redirect()->action($action);
         });
     });
     $router->macro('module', function ($slug, $className, $sortable = false) use($router) {
         if ($sortable) {
             $router->patch("{$slug}/changeOrder", "{$className}Controller@changeOrder");
         }
         $router->resource($slug, "{$className}Controller");
     });
     $router->macro('articleList', function ($technicalNamePrefix, $action) use($router) {
         $articles = app(ArticleRepository::class)->getWithTechnicalNameLike($technicalNamePrefix);
         $router->get(app()->getLocale() . '/' . fragment_slug("navigation.{$technicalNamePrefix}"), function () use($articles) {
             return redirect(route("{$articles->first()->technical_name}"));
         })->name($technicalNamePrefix);
         $articles->map(function ($article) use($technicalNamePrefix, $action, $router) {
             $router->get(app()->getLocale() . '/' . fragment_slug("navigation.{$technicalNamePrefix}") . '/' . $article->url, $action)->name("{$article->technical_name}");
         });
     });
 }
开发者ID:bjrnblm,项目名称:blender,代码行数:26,代码来源:RouteServiceProvider.php

示例5: registerInstanceMacro

 /**
  * Register Router Macro called Instance
  * 플러그인에에서 등록한 route pattern 형태로 등록하여 instance route 를 찾을 수 있도록 하는
  * 매크로 등록
  *
  * @param Router $router to register macro
  *
  * @return void
  */
 protected function registerInstanceMacro(Router $router)
 {
     static $seq = 1;
     $instanceMacro = function ($key, Closure $callback, $routeOptions = null) use(&$seq) {
         $pattern = '{instanceGroup' . $seq++ . '}';
         $attributes = ['prefix' => $pattern, 'module' => $key, 'middleware' => ['access']];
         if ($routeOptions !== null and is_array($routeOptions)) {
             $routeOptions = array_except($routeOptions, ['prefix', 'middleware']);
             $attributes = array_merge($attributes, $routeOptions);
             if (isset($routeOptions['middleware'])) {
                 $attributes['middleware'] .= '|' . $routeOptions['middleware'];
             }
         }
         $this->group($attributes, $callback);
     };
     $router->macro('instance', $instanceMacro);
 }
开发者ID:xpressengine,项目名称:xpressengine,代码行数:26,代码来源:RoutingServiceProvider.php

示例6: registerInstanceMacro

 /**
  * Register Router Macro called Instance
  * 플러그인에에서 등록한 route pattern 형태로 등록하여 instance route 를 찾을 수 있도록 하는
  * 매크로 등록
  *
  * @param Router $router to register macro
  *
  * @return void
  */
 protected function registerInstanceMacro(Router $router)
 {
     $instanceMacro = function ($key, Closure $callback, $routeOptions = null) {
         $pattern = sprintf("%s%s%s", "{", preg_replace("/[@\\/]/", "_", $key), "}");
         $attributes = ['prefix' => $pattern, 'module' => $key, 'middleware' => ['access']];
         if ($routeOptions !== null and is_array($routeOptions)) {
             $routeOptions = array_except($routeOptions, ['prefix', 'middleware']);
             $attributes = array_merge($attributes, $routeOptions);
             if (isset($routeOptions['middleware'])) {
                 $attributes['middleware'] .= '|' . $routeOptions['middleware'];
             }
         }
         $this->group($attributes, $callback);
     };
     $router->macro('instance', $instanceMacro);
 }
开发者ID:mint-soft-com,项目名称:xpressengine,代码行数:25,代码来源:RoutingServiceProvider.php

示例7: registerFixedMacro

 /**
  * Register Router Macro called Fixed
  * fixed 로 호출할 수 있는 Router 매크로를 등록하여
  * 플러그인 고유한 URL 을 가져갈 수 있도록 한다.
  *
  * @param Router $router to register macro
  *
  * @return void
  */
 protected function registerFixedMacro(Router $router)
 {
     $fixedMacro = function ($key, Closure $callback, $routeOptions = null) {
         $newKey = str_replace('@', '/', $key);
         $attributes = ['prefix' => config('xe.routing.fixedPrefix') . '/' . $newKey];
         if ($routeOptions !== null and is_array($routeOptions)) {
             $routeOptions = array_except($routeOptions, ['prefix']);
             $attributes = array_merge($attributes, $routeOptions);
         }
         $this->group($attributes, $callback);
     };
     $router->macro('fixed', $fixedMacro);
 }
开发者ID:xpressengine,项目名称:xpressengine,代码行数:22,代码来源:RoutingServiceProvider.php


注:本文中的Illuminate\Routing\Router::macro方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。