예제 #1
0
 private function setSlimRules($rules)
 {
     foreach ($rules as $controllers) {
         if (isset($controllers['groups'])) {
             $this->slim->group($controllers['pattern'], function () use($controllers) {
                 foreach ($controllers['groups'] as $controller) {
                     $this->map($controller['methods'], $controller['pattern'], $controller['action'])->setName($controller['name']);
                 }
             });
         } else {
             $this->slim->map($controllers['methods'], $controllers['pattern'], $controllers['action'])->setName($controllers['name']);
         }
     }
 }
예제 #2
0
 public function __construct(App $app)
 {
     $app->group('/periodos', function () {
         $this->get('/actual', RetriveActualAction::class);
         $this->get('/{anio}', RetrivePeriodosDelAnio::class);
     });
 }
예제 #3
0
 public function init(\Slim\App $app)
 {
     $app->group('/categories', function () {
         $this->get('', '\\Controllers\\Categories:index');
         $this->map(['GET', 'POST'], '/created', '\\Controllers\\Categories:created');
         $this->map(['GET', 'POST'], '/edit/{id}', '\\Controllers\\Categories:edit');
         $this->map(['GET', 'POST'], '/delete/{id}', '\\Controllers\\Categories:delete');
     });
 }
예제 #4
0
 public function __construct(App $app)
 {
     $app->group('/empleados/{e_id}/solicitudes_pqr', function () {
         $this->get('', RetriveLastSolicitudPQRAction::class);
         $this->post('', CreateNewSolicitudPQRAction::class);
         $this->delete('/{pqr_id}', DeleteSolicitudPQRAction::class);
         $this->post('/{pqr_id}/respuesta', ResponderSolicitudPQRAction::class);
     });
     $app->get('/solicitudes_pqr', RetriveSolicitudesPQRAction::class);
     $app->get('/solicitudes_pqr/{pqr_id}', RetriveOneSolicitudPQRAction::class);
 }
예제 #5
0
 public function __construct(App $app)
 {
     $app->group('/empleados', function () {
         $this->get('/syncup', SyncUP::class);
         $this->get('[/]', RetriveAction::class);
         $this->get('/{e_id}', RetriveAction::class);
         //$this->get('/certificado_laboral/{crt_id}', GenerateCertificadoAction::class);
         $this->get('/{e_id}/certificado_laboral/{tipo_crt}', GenerateCertificadoAction::class);
         #$this->get('/{e_id}', RetriveAction::class);
     });
 }
예제 #6
0
 public function registerRoute(Slim $app)
 {
     $data = $this->getInfo();
     $app->group($data['path'], function () use($data) {
         $this->get('', $data['handle'] . ':index')->setName('list.' . $data['name']);
         $this->get('/add', $data['handle'] . ':add')->setName('add.' . $data['name']);
         $this->get('/edit/{id:\\d+}', $data['handle'] . ':edit')->setName('edit.' . $data['name']);
         $this->map(['PUT', 'POST'], '/add', $data['handle'] . ':doAdd')->setName('store.' . $data['name']);
         $this->map(['PUT', 'POST'], '/edit', $data['handle'] . ':doEdit')->setName('save.' . $data['name']);
         $this->map(['DELETE', 'POST'], '/delete/{id:\\d+}', $data['handle'] . ':doDelete')->setName('delete.' . $data['name']);
     });
 }
예제 #7
0
 /**
  * Register DebugBar service.
  *
  * @param  App $app
  *
  * @return void
  */
 public function register(App $app)
 {
     $container = $app->getContainer();
     $container['debugbar'] = function ($container) {
         return new SlimDebugBar($container, $this->settings);
     };
     if (!$this->settings['enabled']) {
         return;
     }
     $app->group('/_debugbar', function () {
         $this->get('/open', 'Kitchenu\\Debugbar\\Controllers\\OpenHandlerController:handle')->setName('debugbar-openhandler');
         $this->get('/assets/stylesheets', 'Kitchenu\\Debugbar\\Controllers\\AssetController:css')->setName('debugbar-assets-css');
         $this->get('/assets/javascript', 'Kitchenu\\Debugbar\\Controllers\\AssetController:js')->setName('debugbar-assets-js');
     });
     $app->add(new Debugbar($container['debugbar'], $container['errorHandler']));
 }
예제 #8
0
파일: routes.php 프로젝트: bg4kks/ss-panel
$configuration = ['settings' => ['displayErrorDetails' => $debug]];
$c = new Container($configuration);
// Make a Slim App
$app = new App($c);
// Home
$app->get('/', 'App\\Controllers\\HomeController:index');
$app->get('/code', 'App\\Controllers\\HomeController:code');
// User Center
$app->group('/user', function () {
    $this->get('', 'App\\Controllers\\UserController:index');
    $this->get('/', 'App\\Controllers\\UserController:index');
    $this->post('/checkin', 'App\\Controllers\\UserController:doCheckin');
    $this->get('/node', 'App\\Controllers\\UserController:node');
    $this->get('/node/{id}', 'App\\Controllers\\UserController:nodeInfo');
    $this->get('/profile', 'App\\Controllers\\UserController:profile');
    $this->get('/invite', 'App\\Controllers\\UserController:invite');
    $this->post('/invite', 'App\\Controllers\\UserController:doInvite');
    $this->get('/edit', 'App\\Controllers\\UserController:edit');
    $this->post('/password', 'App\\Controllers\\UserController:updatePassword');
    $this->post('/sspwd', 'App\\Controllers\\UserController:updateSsPwd');
    $this->post('/method', 'App\\Controllers\\UserController:updateMethod');
    $this->get('/sys', 'App\\Controllers\\UserController:sys');
    $this->get('/logout', 'App\\Controllers\\UserController:logout');
})->add(new Auth());
// Auth
$app->group('/auth', function () {
    $this->get('/login', 'App\\Controllers\\AuthController:login');
    $this->post('/login', 'App\\Controllers\\AuthController:loginHandle');
    $this->get('/register', 'App\\Controllers\\AuthController:register');
    $this->post('/register', 'App\\Controllers\\AuthController:registerHandle');
    $this->get('/logout', 'App\\Controllers\\AuthController:logout');
})->add(new Guest());
예제 #9
0
/***
 * The slim documents: http://www.slimframework.com/docs/objects/router.html
 */
$app = new App();
// Home
$app->get('/', 'App\\Controllers\\HomeController:home');
$app->get('/code', 'App\\Controllers\\HomeController:code');
// User Center
$app->group('/user', function () {
    $this->get('', 'App\\Controllers\\UserController:home');
    $this->get('/', 'App\\Controllers\\UserController:home');
    $this->post('/checkin', 'App\\Controllers\\UserController:doCheckin');
    $this->get('/node', 'App\\Controllers\\UserController:node');
    $this->get('/node/{id}', 'App\\Controllers\\UserController:nodeInfo');
    $this->get('/profile', 'App\\Controllers\\UserController:profile');
    $this->get('/invite', 'App\\Controllers\\UserController:invite');
    $this->post('/invite', 'App\\Controllers\\UserController:doInvite');
    $this->get('/edit', 'App\\Controllers\\UserController:edit');
    $this->post('/password', 'App\\Controllers\\UserController:updatePassword');
    $this->post('/sspwd', 'App\\Controllers\\UserController:updateSsPwd');
    $this->get('/sys', 'App\\Controllers\\UserController:sys');
    $this->get('/logout', 'App\\Controllers\\UserController:logout');
})->add(new Auth());
// Auth
$app->group('/auth', function () {
    $this->get('/login', 'App\\Controllers\\AuthController:login');
    $this->post('/login', 'App\\Controllers\\AuthController:loginHandle');
    $this->get('/register', 'App\\Controllers\\AuthController:register');
    $this->post('/register', 'App\\Controllers\\AuthController:registerHandle');
    $this->get('/logout', 'App\\Controllers\\AuthController:logout');
})->add(new Guest());
예제 #10
0
 public function __construct(App $app)
 {
     $app->group('/usuarios', function () {
         $this->get('', RetriveAction::class);
     });
 }
 public function testGroupDefaultSlash()
 {
     $app = new App();
     $app->group('/foo', function () use($app) {
         $app->get('/', function ($req, $res) {
             // Do something
         });
     });
     /** @var \Slim\Router $router */
     $router = $app->router;
     $router->finalize();
     $this->assertAttributeEquals('/foo', 'pattern', $router->lookupRoute('route0'));
     $app = new App();
     $app->group('/foo', function () use($app) {
         $app->get('/bar', function ($req, $res) {
             // Do something
         });
     });
     /** @var \Slim\Router $router */
     $router = $app->router;
     $router->finalize();
     $this->assertAttributeEquals('/foo/bar', 'pattern', $router->lookupRoute('route0'));
     $app = new App();
     $app->group('/foo', function () use($app) {
         $app->group('/baz', function () use($app) {
             $app->get('/', function ($req, $res) {
                 // Do something
             });
         });
     });
     /** @var \Slim\Router $router */
     $router = $app->router;
     $router->finalize();
     $this->assertAttributeEquals('/foo/baz', 'pattern', $router->lookupRoute('route0'));
     $app = new App();
     $app->group('/foo', function () use($app) {
         $app->get('/bar/', function ($req, $res) {
             // Do something
         });
     });
     /** @var \Slim\Router $router */
     $router = $app->router;
     $router->finalize();
     $this->assertAttributeEquals('/foo/bar/', 'pattern', $router->lookupRoute('route0'));
 }
예제 #12
0
 /**
  * Sets routing groups to be used on dynamic routing
  *
  * @param \Slim\App $app      Reference to slim app
  * @param string    $group    Main group name
  * @param string    $subGroup Secondary group name
  *
  * @return void
  * @access protected
  */
 private function setGroups(\Slim\App $app, $group, $subGroup = null)
 {
     $ns = $this->namespace;
     $app->group('/' . $group, function () use($subGroup, $ns) {
         // Version group
         if ($subGroup !== null) {
             $this->group('/' . $subGroup, function () use($ns) {
                 \mbarquin\SlimDR\Factory::setMap($this, $ns);
             });
             // End api group.
         } else {
             \mbarquin\SlimDR\Factory::setMap($this, $ns);
         }
     });
 }
예제 #13
0
 public function testEmptyGroupWithEmptyNestedGroupAndSegmentRouteWithoutLeadingSlash()
 {
     $app = new App();
     $app->group('', function () use($app) {
         $app->group('', function () use($app) {
             $app->get('bar', function ($req, $res) {
                 // Do something
             });
         });
     });
     /** @var \Slim\Router $router */
     $router = $app->router;
     $router->finalize();
     $this->assertAttributeEquals('/bar', 'pattern', $router->lookupRoute('route0'));
 }
예제 #14
0
파일: Api.php 프로젝트: i4j5/burgermaniya
 public function init(\Slim\App $app)
 {
     $app->group('/api', function () {
         $this->get('/get-catalog', '\\Controllers\\Api:getCatalog');
     });
 }
예제 #15
0
$app->get('/', 'App\\Controllers\\HomeController:index');
$app->get('/code', 'App\\Controllers\\HomeController:code');
$app->get('/tos', 'App\\Controllers\\HomeController:tos');
$app->get('/debug', 'App\\Controllers\\HomeController:debug');
$app->post('/debug', 'App\\Controllers\\HomeController:postDebug');
// User Center
$app->group('/user', function () {
    $this->get('', 'App\\Controllers\\UserController:index');
    $this->get('/', 'App\\Controllers\\UserController:index');
    $this->post('/checkin', 'App\\Controllers\\UserController:doCheckin');
    $this->get('/node', 'App\\Controllers\\UserController:node');
    $this->get('/node/{id}', 'App\\Controllers\\UserController:nodeInfo');
    $this->get('/profile', 'App\\Controllers\\UserController:profile');
    $this->get('/invite', 'App\\Controllers\\UserController:invite');
    $this->post('/invite', 'App\\Controllers\\UserController:doInvite');
    $this->get('/edit', 'App\\Controllers\\UserController:edit');
    $this->post('/password', 'App\\Controllers\\UserController:updatePassword');
    $this->post('/sspwd', 'App\\Controllers\\UserController:updateSsPwd');
    $this->post('/method', 'App\\Controllers\\UserController:updateMethod');
    $this->get('/sys', 'App\\Controllers\\UserController:sys');
    $this->get('/trafficlog', 'App\\Controllers\\UserController:trafficLog');
    $this->get('/kill', 'App\\Controllers\\UserController:kill');
    $this->post('/kill', 'App\\Controllers\\UserController:handleKill');
    $this->get('/logout', 'App\\Controllers\\UserController:logout');
})->add(new Auth());
// Auth
$app->group('/auth', function () {
    $this->get('/login', 'App\\Controllers\\AuthController:login');
    $this->post('/login', 'App\\Controllers\\AuthController:loginHandle');
    $this->get('/register', 'App\\Controllers\\AuthController:register');
    $this->post('/register', 'App\\Controllers\\AuthController:registerHandle');
예제 #16
0
 public function testGroup()
 {
     $app = new App();
     $app->group('/foo', function () use($app) {
         $route = $app->get('/bar', function ($req, $res) {
             // Do something
         });
     });
     /** @var \Slim\Router $router */
     $router = $app->router;
     $router->finalize();
     $this->assertAttributeEquals('/foo/bar', 'pattern', $router->getRoutes()[0]);
 }
예제 #17
0
use Slim\App;
use App\Controllers;
use App\Middleware\Auth;
use App\Middleware\Guest;
/***
 * The slim documents: http://www.slimframework.com/docs/objects/router.html
 */
$app = new App();
// Home
$app->get('/', 'App\\Controllers\\HomeController:home');
$app->get('/code', 'App\\Controllers\\HomeController:code');
// User Center
$app->group('/user', function () {
    $this->get('/', 'App\\Controllers\\UserController:home');
    $this->get('/node', 'App\\Controllers\\UserController:node');
    $this->get('/profile', 'App\\Controllers\\UserController:profile');
    $this->get('/invite', 'App\\Controllers\\UserController:invite');
    $this->get('/sys', 'App\\Controllers\\UserController:sys');
    $this->get('/logout', 'App\\Controllers\\UserController:logout');
})->add(new Auth());
// Auth
$app->group('/auth', function () {
    $this->get('/login', 'App\\Controllers\\AuthController:login');
    $this->post('/login', 'App\\Controllers\\AuthController:loginHandle');
    $this->get('/register', 'App\\Controllers\\AuthController:register');
    $this->post('/register', 'App\\Controllers\\AuthController:registerHandle');
    $this->get('/logout', 'App\\Controllers\\AuthController:logout');
})->add(new Guest());
// Run Slim Routes for App
$app->run();
예제 #18
0
 public function testAddMiddlewareOnRouteAndOnTwoRouteGroup()
 {
     $app = new App();
     $app->group('/foo', function () use($app) {
         $app->group('/baz', function () use($app) {
             $app->get('/', function ($req, $res) {
                 return $res->write('Center');
             })->add(function ($req, $res, $next) {
                 $res->write('In3');
                 $res = $next($req, $res);
                 $res->write('Out3');
                 return $res;
             });
         })->add(function ($req, $res, $next) {
             $res->write('In2');
             $res = $next($req, $res);
             $res->write('Out2');
             return $res;
         });
     })->add(function ($req, $res, $next) {
         $res->write('In1');
         $res = $next($req, $res);
         $res->write('Out1');
         return $res;
     });
     // Prepare request and response objects
     $env = Environment::mock(['SCRIPT_NAME' => '/index.php', 'REQUEST_URI' => '/foo/baz/', 'REQUEST_METHOD' => 'GET']);
     $uri = Uri::createFromEnvironment($env);
     $headers = Headers::createFromEnvironment($env);
     $cookies = [];
     $serverParams = $env->all();
     $body = new RequestBody();
     $req = new Request('GET', $uri, $headers, $cookies, $serverParams, $body);
     $res = new Response();
     // Invoke app
     $app($req, $res);
     $this->assertEquals('In1In2In3CenterOut3Out2Out1', (string) $res->getBody());
 }