Router PHP Class Code Examples

This page contains top rated real world PHP examples of class Router extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: RouterMvcTest.php Project: UqiOnline/cphalcon7
0
 public function testRegex()
 {
     Phalcon\Mvc\Router\Route::reset();
     $router = new Phalcon\Mvc\Router(false);
     $router->add('/:controller/:action/:params', array("controller" => 1, "action" => 2, "params" => 3));
     $router->handle('/c/a/p');
     $this->assertEquals($router->getMatches(), array(0 => '/c/a/p', 1 => 'c', 2 => 'a', 3 => '/p'));
     Phalcon\Mvc\Router\Route::reset();
     $router = new Phalcon\Mvc\Router(false);
     $router->add('/:controller/:action:params', array("controller" => 1, "action" => 2, "params" => 3), array(':controller' => '([a-zA-Z0-9_-]+)', ':action' => '([a-zA-Z0-9_-]+)', ':params' => '(/[a-zA-Z0-9_-]+)?'));
     $router->handle('/c/a/p');
     $this->assertEquals($router->getMatches(), array(0 => '/c/a/p', 1 => 'c', 2 => 'a', 3 => '/p'));
     Phalcon\Mvc\Router\Route::reset();
     $router = new Phalcon\Mvc\Router(false);
     $router->add(':controller:action:params', array("controller" => 1, "action" => 2, "params" => 3), array(':controller' => '/([a-zA-Z0-9_-]+)', ':action' => '/([a-zA-Z0-9_-]+)', ':params' => '(/[a-zA-Z0-9_-]+)?'));
     $router->handle('/c/a/p');
     $this->assertEquals($router->getMatches(), array(0 => '/c/a/p', 1 => 'c', 2 => 'a', 3 => '/p'));
     Phalcon\Mvc\Router\Route::reset();
     $router = new Phalcon\Mvc\Router(false);
     $router->add('/(:controller(/:action(/:params)?)?)?', array("controller" => 2, "action" => 4, "params" => 5), array(':controller' => '([a-zA-Z0-9_-]+)', ':action' => '([a-zA-Z0-9_-]+)', ':params' => '([a-zA-Z0-9_-]+)?'));
     $router->handle('/c/a/p');
     $this->assertEquals($router->getMatches(), array(0 => '/c/a/p', 1 => 'c/a/p', 2 => 'c', 3 => '/a/p', 4 => 'a', 5 => '/p', 6 => 'p'));
     $router->handle('/c/a');
     $this->assertEquals($router->getMatches(), array(0 => '/c/a', 1 => 'c/a', 2 => 'c', 3 => '/a', 4 => 'a'));
     $router->handle('/c');
     $this->assertEquals($router->getMatches(), array(0 => '/c', 1 => 'c', 2 => 'c'));
 }
Example #2
Show file File: RouteServiceProvider.php Project: afelipelc/Bachilleratos-Digitales-Laravel
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->model('school', School::class);
     $router->model('inscription', Inscription::class);
     $router->model('student', Student::class);
     parent::boot($router);
 }
Example #3
Show file File: OAuthClientServiceProvider.php Project: xwiz/laravel-oauth2-client
0
 /**
  * Bootstrap application services.
  *
  * @param Router $router
  */
 public function boot(Router $router)
 {
     $configPath = __DIR__ . '/../config/laravel-oauth2-client.php';
     $this->publishes([$configPath => config_path('laravel-oauth2-client.php')], 'config');
     $this->loginRoute($router);
     $this->logoutRoute($router);
 }
Example #4
Show file File: FacebookHelper.php Project: MrMitch/Les-Joies-de-Supinfo
0
 public static function getFacebookLikesGroupedBySubmitter(array $gifs, Router $router)
 {
     $json = FacebookHelper::getLikes($gifs, $router);
     $submitters = [];
     foreach ($json as $item) {
         $url = $item['url'];
         $likesCount = intval($item['total_count']);
         /** @var Gif $gif */
         $gif = FacebookHelper::findGif($gifs, $url);
         if (!array_key_exists($gif->getSubmittedBy(), $submitters)) {
             $submitters[$gif->getSubmittedBy()] = ['gifs' => [], 'likes' => 0];
         }
         $submitters[$gif->getSubmittedBy()]['gifs'][] = $gif;
         $submitters[$gif->getSubmittedBy()]['likes'] += $likesCount;
     }
     // Sort array
     $submittersIndexed = [];
     foreach ($submitters as $submitter => $infos) {
         $submittersIndexed[] = ['submitter' => $submitter, 'gifs' => $infos['gifs'], 'likes' => $infos['likes']];
     }
     usort($submittersIndexed, function ($a, $b) {
         return $b['likes'] - $a['likes'];
     });
     return $submittersIndexed;
 }
Example #5
Show file File: ApplicationMvcTest.php Project: aisuhua/phalcon-php
0
 public function testApplicationModulesDefinitionClosure()
 {
     // Creates the autoloader
     $loader = new \Phalcon\Loader();
     $loader->registerNamespaces(array('Frontend\\Controllers' => __DIR__ . '/modules/frontend/controllers/', 'Backend\\Controllers' => __DIR__ . '/modules/backend/controllers/'));
     $loader->register();
     $_GET['_url'] = '/login';
     Phalcon\DI::reset();
     $di = new Phalcon\DI\FactoryDefault();
     $di->set('router', function () {
         $router = new Phalcon\Mvc\Router(false);
         $router->add('/index', array('controller' => 'index', 'module' => 'frontend', 'namespace' => 'Frontend\\Controllers\\'));
         $router->add('/login', array('controller' => 'login', 'module' => 'backend', 'namespace' => 'Backend\\Controllers\\'));
         return $router;
     });
     $application = new Phalcon\Mvc\Application();
     $view = new \Phalcon\Mvc\View();
     $application->registerModules(array('frontend' => function ($di) use($view) {
         $di->set('view', function () use($view) {
             $view = new \Phalcon\Mvc\View();
             $view->setViewsDir(__DIR__ . '/modules/frontend/views/');
             return $view;
         });
     }, 'backend' => function ($di) use($view) {
         $di->set('view', function () use($view) {
             $view->setViewsDir(__DIR__ . '/modules/backend/views/');
             return $view;
         });
     }));
     $application->setDi($di);
     $this->assertEquals($application->handle()->getContent(), '<html>here</html>' . PHP_EOL);
     $loader->unregister();
 }
Example #6
Show file File: RouteServiceProvider.php Project: wyrover/refund-api
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param \Illuminate\Routing\Router $router
  *
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     $router->model('users', 'App\\User', function () {
         throw new UserNotFoundException();
     });
     $router->model('regions', 'App\\Region', function () {
         throw new RegionNotFoundException();
     });
     $router->model('provision_types', 'App\\ProvisionType', function () {
         throw new ProvisionTypeNotFoundException();
     });
     $router->model('funds', 'App\\Fund', function () {
         throw new FundNotFoundException();
     });
     $router->model('providers', 'App\\Provider', function () {
         throw new ProviderNotFoundException();
     });
     $router->model('organisation_types', 'App\\OrganisationType', function () {
         throw new OrganisationTypeNotFoundException();
     });
     $router->model('locations', 'App\\Location', function () {
         throw new LocationNotFoundException();
     });
     $router->model('countries', 'App\\Country', function () {
         throw new CountryNotFoundException();
     });
 }
Example #7
Show file File: RouterTest.php Project: Ye-Yong-Chi/beautyUniversity
0
 public function testSubrouteMouting()
 {
     // Create Router
     $router = new \Bramus\Router\Router();
     $router->mount('/movies', function () use($router) {
         $router->get('/', function () {
             echo 'overview';
         });
         $router->get('/(\\d+)', function ($id) {
             echo htmlentities($id);
         });
     });
     // Test the /movies route
     ob_start();
     $_SERVER['REQUEST_URI'] = '/movies';
     $router->run();
     $this->assertEquals('overview', ob_get_contents());
     // Test the /hello/bramus route
     ob_clean();
     $_SERVER['REQUEST_URI'] = '/movies/1';
     $router->run();
     $this->assertEquals('1', ob_get_contents());
     // Cleanup
     ob_end_clean();
 }
Example #8
Show file File: RouteServiceProvider.php Project: hongpyo/l5essential
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->pattern('id', '[0-9]+');
     // Should handle 32n33-sss-img-dd.png exception
     $router->pattern('image', '(?P<parent>[0-9n]{2,5}-[\\pL-\\pN\\._-]+)-(?P<suffix>img-[0-9]{2}.png)');
     parent::boot($router);
 }
Example #9
Show file File: RouteServiceProvider.php Project: kpaxer/shcms
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     \Route::bind('category', function ($value) {
         return \App\Model\Option::where('id', $value)->first();
     });
 }
Example #10
Show file File: NavBar.php Project: cscfa/NavBarBundle
0
 /**
  * Create element
  * 
  * Create a navbar element
  * from an element array
  * configuration
  * 
  * @param string $name   - the element name
  * @param array  $array  - the element configuration
  * @param router $router - the application router
  * 
  * @throws \Exception
  * @return NavBar - the current instance
  */
 protected function createElement($name, $array, Router $router)
 {
     $element = new NavBarElement();
     $element->setName($name)->setLabel($name);
     foreach ($array as $key => $value) {
         switch ($key) {
             case 'label':
                 $element->setLabel($value);
                 break;
             case 'roles':
                 $element->setRoles($value);
                 break;
             case 'path':
                 $element->setPath($this->generateRoute($name, $value, $router));
                 break;
             case 'url':
                 $element->setPath($value);
                 break;
             case 'parent':
                 // nothing
                 break;
             case 'options':
                 $element->setOptions($value);
                 break;
             case 'position':
                 $element->setPosition($value);
                 break;
             default:
                 throw new \Exception(sprintf("The '%s' key for navbar element does not exist. Allowed : 'label', 'roles', 'path', 'parent', 'url', 'options', 'position'", $value), 500);
         }
     }
     return $element;
 }
Example #11
Show file File: RouterTest.php Project: mechiko/staff-october
0
 public function testUrl()
 {
     $params = array();
     $router = new Router();
     // Set up some dummy rules
     $router->route('authorDetails', '/authors/:author_id?/:details?');
     $router->route('blogPost', 'blog/post');
     $router->route('userProfile', 'profile/:username');
     $router->route('jobRequest', 'job/:type?request/:id');
     $router->route('productPage', '/product/:category?/:id');
     $result = $router->url('blogPost');
     $this->assertEquals('/blog/post', $result);
     $result = $router->url('authorDetails');
     $this->assertEquals('/authors', $result);
     $result = $router->url('authorDetails', array('author_id' => 20));
     $this->assertEquals('/authors/20', $result);
     $result = $router->url('authorDetails', array('details' => 'history'));
     $this->assertEquals('/authors/default/history', $result);
     $result = $router->url('userProfile', array('username' => 'shaq'));
     $this->assertEquals('/profile/shaq', $result);
     $result = $router->url('jobRequest', array('id' => '9'));
     $this->assertEquals('/job/request/9', $result);
     $result = $router->url('jobRequest');
     $this->assertEquals('/job/request/default', $result);
     $result = $router->url('productPage', array('id' => '7'));
     $this->assertEquals('/product/default/7', $result);
     $result = $router->url('productPage', array('id' => '7', 'category' => 'helmets'));
     $this->assertEquals('/product/helmets/7', $result);
 }
Example #12
Show file File: RouteServiceProvider.php Project: Soul0806/MyWeb
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('user', function ($value) {
         //return User::where('name', $value)->first();
     });
 }
Example #13
Show file File: RouteServiceProvider.php Project: jesusave/laracarte
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->bind('username', function ($username) {
         return User::whereUsername($username)->first();
     });
     parent::boot($router);
 }
Example #14
Show file File: AuraRouter.php Project: weierophinney/zend-expressive-aurarouter
0
 /**
  * Constructor
  *
  * If no Aura.Router instance is provided, the constructor will lazy-load
  * an instance. If you need to customize the Aura.Router instance in any
  * way, you MUST inject it yourself.
  *
  * @param null|Router $router
  */
 public function __construct(Router $router = null)
 {
     if (null === $router) {
         $router = $this->createRouter();
     }
     $this->router = $router;
 }
Example #15
Show file File: RouteServiceProvider.php Project: MP86/App
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     // $router->model('amministratori', \App\Amministratore::class);                         /* versione semplice */
     $router->bind('amministratori', function ($id) {
         /*versione con opzioni specifiche*/
         return \App\Amministratore::where('id', $id)->FirstOrFail();
     });
     $router->bind('utenti', function ($id) {
         /*versione con opzioni specifiche*/
         return \App\Utente::where('id', $id)->FirstOrFail();
     });
     $router->bind('aziende', function ($id) {
         /*versione con opzioni specifiche*/
         return \App\Azienda::where('id', $id)->FirstOrFail();
     });
     $router->bind('problemi', function ($id) {
         /*versione con opzioni specifiche*/
         return \App\Problema::where('id', $id)->FirstOrFail();
     });
     $router->bind('preventivi', function ($id) {
         /*versione con opzioni specifiche*/
         return \App\Preventivo::where('id', $id)->FirstOrFail();
     });
     parent::boot($router);
 }
Example #16
Show file File: RouteServiceProvider.php Project: highorcorrea/Laravel
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     $router->model('category', 'CodeCommerce\\Category');
     $router->model('products', 'CodeCommerce\\Product');
 }
Example #17
Show file File: RouteServiceProvider.php Project: snyh/just-calc-dstore-info
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     //所有的Route的id参数都会进行此验证/user/{id}
     $router->pattern("id", '[0-9]+');
     parent::boot($router);
 }
Example #18
Show file File: RouteServiceProvider.php Project: villeglad/comex
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     $router->model('companies', 'App\\Company');
     $router->model('businessLines', 'App\\BusinessLine');
 }
Example #19
Show file File: RouteServiceProvider.php Project: jxjjdccj/StuGradeWithLaravel5
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('admin', function ($id) {
         return \App\User::findOrFail($id);
     });
 }
Example #20
Show file File: field.php Project: irenehilber/kirby-base
0
 public function route($model, $form, $fieldName, $fieldType, $path)
 {
     $field = $form->fields()->{$fieldName};
     if (!$field or $field->type() !== $fieldType) {
         throw new Exception('Invalid field');
     }
     $routes = $field->routes();
     $router = new Router($routes);
     if ($route = $router->run($path)) {
         if (is_callable($route->action()) and is_a($route->action(), 'Closure')) {
             return call($route->action(), $route->arguments());
         } else {
             $controllerFile = $field->root() . DS . 'controller.php';
             $controllerName = $fieldType . 'FieldController';
             if (!file_exists($controllerFile)) {
                 throw new Exception(l('fields.error.missing.controller'));
             }
             require_once $controllerFile;
             if (!class_exists($controllerName)) {
                 throw new Exception(l('fields.error.missing.class'));
             }
             $controller = new $controllerName($model, $field);
             return call(array($controller, $route->action()), $route->arguments());
         }
     } else {
         throw new Exception(l('fields.error.route.invalid'));
     }
 }
Example #21
Show file File: index.php Project: kazuohirai/awayfromswag
0
function main()
{
    DatabaseProvider::connect("app/config/database.json");
    BaseViewContextProvider::setProvider(function () {
        return ['count' => ['event' => (new EventModel())->count()['nb'], 'user' => (new UserModel())->count()['nb'], 'online' => (new LittleModel())->checkConnect()['COUNT(*)']], 'newmessages' => Authentication::getInstance()->isAuthenticated() ? (new ConversationModel())->countUnreadMessages() : 0];
    });
    $router = new \SwagFramework\Routing\Router();
    $classRouting = new ClassRouting('\\app\\controllers\\');
    $classRouting->addClass('User');
    $classRouting->addClass('Event');
    $classRouting->addClass('Article');
    $classRouting->addClass('Parteners');
    $classRouting->addClass('Search');
    if (Authentication::getInstance()->isAuthenticated()) {
        $classRouting->addClass('Conversation');
        if (Authentication::getInstance()->getOptionOr('accessLevel', 0)) {
            $classRouting->addClass('AdminUsers');
            $classRouting->addClass('AdminEvent');
            $classRouting->addClass('AdminComment');
            $classRouting->addClass('Admin');
        }
    }
    $classRouting->generateRoute($router);
    $router->add('/errors/err404', new \app\controllers\ErrorsController(), 'err404');
    $router->add('/', new \app\controllers\HomeController(), 'index');
    $router->matchCurrentRequest();
}
Example #22
Show file File: Router.class.php Project: wAmpIre/netmon
0
 public function store()
 {
     if ($this->getUserId() != 0 and $this->getHostname() != "" and $this->getCrawlMethod() != "" and $this->getChipsetId() != 0) {
         $router_test = new Router(false, false, $this->getHostname());
         $router_test->fetch();
         if ($this->getRouterId() != 0 and !($router_test->getRouterId() != $this->getRouterId() and $router_test->getHostname() == $this->getHostname())) {
             try {
                 $stmt = DB::getInstance()->prepare("UPDATE routers SET\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuser_id = ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\thostname = ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdescription = ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlocation = ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlatitude = ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlongitude = ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tchipset_id = ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcrawl_method = ?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tupdate_date = NOW()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE id=?");
                 $stmt->execute(array($this->getUserId(), $this->getHostname(), $this->getDescription(), $this->getLocation(), $this->getLatitude(), $this->getLongitude(), $this->getChipsetId(), $this->getCrawlMethod(), $this->getRouterId()));
                 return $stmt->rowCount();
             } catch (PDOException $e) {
                 echo $e->getMessage();
                 echo $e->getTraceAsString();
             }
         } elseif ($router_test->getRouterId() == 0) {
             try {
                 $stmt = DB::getInstance()->prepare("INSERT INTO routers (user_id, hostname, description, location, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlatitude, longitude, chipset_id, crawl_method,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcreate_date, update_date)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tVALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())");
                 $stmt->execute(array($this->getUserId(), $this->getHostname(), $this->getDescription(), $this->getLocation(), $this->getLatitude(), $this->getLongitude(), $this->getChipsetId(), $this->getCrawlMethod()));
                 $this->setRouterId((int) DB::getInstance()->lastInsertId());
                 //create event for new router
                 $event = new Event(false, false, 'router', $this->getRouterId(), 'new', array('hostname' => $router->getHostname()));
                 $event->store();
                 return $this->getRouterId();
             } catch (PDOException $e) {
                 echo $e->getMessage();
                 echo $e->getTraceAsString();
             }
         }
     }
     return false;
 }
Example #23
Show file File: RouteServiceProvider.php Project: richardkeep/tracker
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->model('batch', 'App\\Batch');
     $router->model('parcel', 'App\\Parcels');
     $router->model('users', 'App\\User');
     parent::boot($router);
 }
Example #24
Show file File: WampErrorExceptionTest.php Project: binaek89/Thruway
0
 function testWampErrorException()
 {
     $loop = \React\EventLoop\Factory::create();
     $router = new \Thruway\Peer\Router($loop);
     //$router->addTransportProvider(new \Thruway\Transport\RawSocketTransportProvider());
     $client = new \Thruway\Peer\Client("realm1", $loop);
     $client->setAttemptRetry(false);
     $client->on('open', function (\Thruway\ClientSession $session) use($router) {
         $session->register('procedure_with_exception', function ($args) {
             throw new \Thruway\Exception\WampErrorException("error.from.exception", $args, (object) ["theKw" => "great"], (object) ["more_details" => "some_more_details"]);
         })->then(function () use($session, $router) {
             $session->call('procedure_with_exception', ['one', 'two'])->then(function ($args) use($router) {
                 $this->fail('Call with wamp exception should not have succeeded.');
                 $router->stop();
             }, function ($err) use($router) {
                 /** @var \Thruway\Message\ErrorMessage $err */
                 $this->assertInstanceOf('Thruway\\Message\\ErrorMessage', $err);
                 $this->assertTrue(is_array($err->getArguments()));
                 $this->assertEquals(2, count($err->getArguments()));
                 $this->assertEquals("one", $err->getArguments()[0]);
                 $this->assertEquals("two", $err->getArguments()[1]);
                 $this->assertInstanceOf('stdClass', $err->getArgumentsKw());
                 $this->assertObjectHasAttribute('theKw', $err->getArgumentsKw());
                 $this->assertEquals('great', $err->getArgumentsKw()->theKw);
                 $this->assertObjectHasAttribute('more_details', $err->getDetails());
                 $this->assertEquals('some_more_details', $err->getDetails()->more_details);
                 $this->assertEquals('error.from.exception', $err->getErrorURI());
                 $router->stop();
             });
         });
     });
     //$client->addTransportProvider(new \Thruway\Transport\RawSocketClientTransportProvider());
     $router->addInternalClient($client);
     $router->start();
 }
Example #25
Show file File: Kernel.php Project: alexandre-le-borgne/-PHP-DUT-S3-Projet
0
 public function generateResponse($route = null, $params = array(), $internal = false)
 {
     $router = new Router();
     $request = Request::getInstance();
     $request->setInternal($internal);
     if ($route) {
         $route = $router->getRoute($route);
     } else {
         $route = $router->getDefaultRoute();
     }
     $controller = $route->getController();
     $action = $route->getAction();
     $controller = new $controller();
     $r = new ReflectionMethod($controller, $action);
     $paramsOfFunction = $r->getParameters();
     $paramsToPass = array();
     $indexParams = 0;
     foreach ($paramsOfFunction as $param) {
         if ($param->getClass() != NULL && $param->getClass()->getName() == 'Request') {
             $paramsToPass[] = $request;
         } else {
             if (isset($params[$indexParams])) {
                 $paramsToPass[] = $params[$indexParams++];
             } else {
                 $paramsToPass[] = null;
             }
         }
     }
     if (!empty($paramsToPass)) {
         return call_user_func_array(array($controller, $action), $paramsToPass);
     }
     return $controller->{$action}();
 }
Example #26
Show file File: RouteServiceProvider.php Project: crow1796/technologyRIS
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     $router->bind('devices', function ($slug) {
         return \App\Device::findBySlugOrFail($slug);
     });
     $router->bind('types', function ($slug) {
         return \App\DeviceType::findBySlugOrFail($slug);
     });
     $router->bind('locations', function ($slug) {
         return \App\DeviceLocation::findBySlugOrFail($slug);
     });
     $router->bind('admins', function ($slug) {
         return \App\User::findBySlugOrFail($slug);
     });
     $router->bind('systemusers', function ($slug) {
         return \App\User::findBySlugOrFail($slug);
     });
     $router->bind('activitylogs', function ($id) {
         return \App\Activity::findOrFail($id);
     });
     $router->bind('userlogs', function ($id) {
         return \App\UserLog::findOrFail($id);
     });
     $router->bind('authuser', function ($slug) {
         return \App\User::findBySlugOrFail($slug);
     });
 }
Example #27
Show file File: Mvc.php Project: suyuanen/trotri
0
 /**
  * 设置路由器
  * @param \tfc\mvc\Router $router
  * @return void
  */
 public static function setRouter(Router $router = null)
 {
     if ($router === null) {
         $router = new Router();
     }
     self::$_router = $router;
 }
Frequently Used Methods