Beispiel #1
0
 public function resource($route, $controller, $additionals = [])
 {
     $collection = new \Phalcon\Mvc\Micro\Collection();
     $collection->setPrefix($route);
     $collection->setHandler(new $controller());
     $collection->get('/', 'getAll');
     $collection->get('/{id}', 'get');
     $collection->post('/', 'create');
     $collection->put('/{id}', 'update');
     $collection->delete('/{id}', 'delete');
     $this->mount($collection);
 }
/**
 * Collections let us define groups of routes that will all use the same controller.
 * We can also set the handler to be lazy loaded.  Collections can share a common prefix.
 * @var $exampleCollection
 */
// This is an Immeidately Invoked Function in php.  The return value of the
// anonymous function will be returned to any file that "includes" it.
// e.g. $collection = include('example.php');
return call_user_func(function () {
    $collection = new \Phalcon\Mvc\Micro\Collection();
    $collection->setPrefix('/api/wordType')->setHandler('\\Base\\Controllers\\Dictionary\\WordTypeController')->setLazy(true);
    // Set Access-Control-Allow headers.
    $collection->options('/', 'optionsBase');
    $collection->options('/{id}', 'optionsOne');
    // First paramter is the route, which with the collection prefix here would be GET /example/
    // Second paramter is the function name of the Controller.
    $collection->get('/', 'get');
    // This is exactly the same execution as GET, but the Response has no body.
    $collection->head('/', 'get');
    // $id will be passed as a parameter to the Controller's specified function
    $collection->get('/{id:[0-9]+}', 'getOne');
    $collection->head('/{id:[0-9]+}', 'getOne');
    $collection->post('/create', 'create');
    $collection->post('/search', 'search');
    $collection->post('/update', 'update');
    $collection->delete('/{id:[0-9]+}', 'delete');
    $collection->put('/{id:[0-9]+}', 'put');
    $collection->patch('/{id:[0-9]+}', 'patch');
    return $collection;
});
Beispiel #3
0
<?php

/**
 * Collections let us define groups of routes that will all use the same controller.
 * We can also set the handler to be lazy loaded.  Collections can share a common prefix.
 * @var $channelsCollection
 */
// This is an Immediately Invoked Function in php.  The return value of the
// anonymous function will be returned to any file that "includes" it.
// e.g. $collection = include('channels.php');
return call_user_func(function () {
    $channelsCollection = new \Phalcon\Mvc\Micro\Collection();
    $channelsCollection->setPrefix('/' . $this->di->getConfig()->application->version . '/channels')->setHandler('\\App\\Modules\\Backend\\Controllers\\ChannelsController')->setLazy(true);
    // Set Access-Control-Allow headers.
    $channelsCollection->options('/', 'optionsBase');
    $channelsCollection->options('/{id}', 'optionsOne');
    // First paramter is the route, which with the collection prefix here would be GET /channels/
    // Second paramter is the function name of the Controller.
    $channelsCollection->get('/', 'get');
    // This is exactly the same execution as GET, but the Response has no body.
    $channelsCollection->head('/', 'get');
    $channelsCollection->post('/search', 'search');
    $channelsCollection->post('/search/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'searchOne');
    // $id will be passed as a parameter to the Controller's specified function
    $channelsCollection->get('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'getOne');
    $channelsCollection->head('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'getOne');
    $channelsCollection->post('/', 'post');
    $channelsCollection->delete('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'delete');
    $channelsCollection->put('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'put');
    return $channelsCollection;
});
Beispiel #4
0
<?php

/**
 * Standard routes for resource
 * Refer to routes/collections/example.php for further details
 */
return call_user_func(function () {
    $routes = new \Phalcon\Mvc\Micro\Collection();
    // VERSION NUMBER SHOULD BE FIRST URL PARAMETER, ALWAYS
    // setHandler MUST be a string in order to support lazy loading
    $routes->setPrefix('/v1/events')->setHandler('\\PhalconRest\\Controllers\\EventController')->setLazy(true);
    $routes->options('/', 'optionsBase');
    $routes->options('/{id}', 'optionsOne');
    $routes->get('/', 'get');
    $routes->head('/', 'get');
    $routes->post('/', 'post');
    $routes->get('/{id:[0-9]+}', 'getOne');
    $routes->head('/{id:[0-9]+}', 'getOne');
    $routes->delete('/{id:[0-9]+}', 'delete');
    $routes->put('/{id:[0-9]+}', 'put');
    $routes->patch('/{id:[0-9]+}', 'patch');
    return $routes;
});
/**
 * Collections let us define groups of routes that will all use the same controller.
 * We can also set the handler to be lazy loaded.  Collections can share a common prefix.
 * @var $productsOptionsCollection
 */
// This is an Immediately Invoked Function in php.  The return value of the
// anonymous function will be returned to any file that "includes" it.
// e.g. $collection = include('products_options.php');
return call_user_func(function () {
    $productsOptionsCollection = new \Phalcon\Mvc\Micro\Collection();
    $productsOptionsCollection->setPrefix('/' . $this->di->getConfig()->application->version . '/products_options')->setHandler('\\App\\Modules\\Backend\\Controllers\\ProductsOptionsController')->setLazy(true);
    // Set Access-Control-Allow headers.
    $productsOptionsCollection->options('/', 'optionsBase');
    $productsOptionsCollection->options('/{id}', 'optionsOne');
    // First paramter is the route, which with the collection prefix here would be GET /products_options/
    // Second paramter is the function name of the Controller.
    $productsOptionsCollection->get('/', 'get');
    // This is exactly the same execution as GET, but the Response has no body.
    $productsOptionsCollection->head('/', 'get');
    // $id will be passed as a parameter to the Controller's specified function
    $productsOptionsCollection->get('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'getOne');
    $productsOptionsCollection->head('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'getOne');
    $productsOptionsCollection->post('/', 'post');
    $productsOptionsCollection->post('/search', 'search');
    $productsOptionsCollection->post('/search/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'searchOne');
    $productsOptionsCollection->delete('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'delete');
    $productsOptionsCollection->put('/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'put');
    $productsOptionsCollection->put('/upload/{id:' . $this->di->getConfig()->application->idRegExp . '+}', 'upload');
    $productsOptionsCollection->put('/import', 'bulkImport');
    return $productsOptionsCollection;
});
Beispiel #6
0
/**
 * Created by PhpStorm.
 * User: Dapo
 * Date: 09-Dec-14
 * Time: 1:43 PM
 */
return call_user_func(function () {
    $api = new \Phalcon\Mvc\Micro\Collection();
    $api->setPrefix('/v1')->setHandler('\\PhalconRest\\Controllers\\AppController')->setLazy(true);
    $api->get('/legalHeads', 'getLegalHeads');
    $api->post('/setStandard', 'setAsStandard');
    $api->post('/updateSubjectMatter', 'updateSubjectMatter');
    $api->post('/changeLegalHead', 'changeLegalHead');
    $api->post('/changeSubjectMatter', 'changeSubjectMatter');
    $api->post('/updateIssue', 'updateIssue');
    $api->post('/mergeSubjectMatters', 'mergeSubjectMatters');
    $api->post('/mergeIssues', 'mergeIssues');
    $api->post('/detachRatio', 'detachRatio');
    $api->post('/markDone', 'markDone');
    $api->post('/removeStandard', 'removeStandard');
    $api->post('/newBookCase/{id:[0-9]+}', 'newBookCase');
    $api->get('/bookCases/{id:[0-9]+}', 'getCases');
    $api->get('/alternateCitations/{id:[0-9]+}', 'getCaseAlternateCitations');
    $api->get('/fullCases', 'fullCases');
    $api->get('/fullCases/{id:[0-9]+}/{term}', 'fullCases');
    $api->get('/fullCases/{id:[0-9]+}/{term}/{type}', 'fullCases');
    $api->get('/caseList/{term}', 'caseList');
    $api->delete('/deleteCase/{id:[0-9]+}', 'deleteCase');
    return $api;
});
Beispiel #7
0
<?php

/**
 * Collections let us define groups of routes that will all use the same controller.
 * We can also set the handler to be lazy loaded.  Collections can share a common prefix.
 * @var $exampleCollection
 */
// This is an Immeidately Invoked Function in php.  The return value of the
// anonymous function will be returned to any file that "includes" it.
// e.g. $collection = include('example.php');
return call_user_func(function () {
    $exampleCollection = new \Phalcon\Mvc\Micro\Collection();
    $exampleCollection->setPrefix('/v1/example')->setHandler('\\PhalconRest\\Controllers\\ExampleController')->setLazy(true);
    // Set Access-Control-Allow headers.
    $exampleCollection->options('/', 'optionsBase');
    $exampleCollection->options('/{id}', 'optionsOne');
    // First paramter is the route, which with the collection prefix here would be GET /example/
    // Second paramter is the function name of the Controller.
    $exampleCollection->get('/', 'get');
    // This is exactly the same execution as GET, but the Response has no body.
    $exampleCollection->head('/', 'get');
    // $id will be passed as a parameter to the Controller's specified function
    $exampleCollection->get('/{id:[0-9]+}', 'getOne');
    $exampleCollection->head('/{id:[0-9]+}', 'getOne');
    $exampleCollection->post('/', 'post');
    $exampleCollection->delete('/{id:[0-9]+}', 'delete');
    $exampleCollection->put('/{id:[0-9]+}', 'put');
    $exampleCollection->patch('/{id:[0-9]+}', 'patch');
    return $exampleCollection;
});