本文整理汇总了PHP中Slim\Slim::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Slim::delete方法的具体用法?PHP Slim::delete怎么用?PHP Slim::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slim\Slim
的用法示例。
在下文中一共展示了Slim::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enable
public function enable(Slim $app)
{
$this->app = $app;
$this->config = $this->app->config('api');
$this->factory = new Factory($this->config['resources']);
// Middleware
$this->app->add(new Database());
$this->app->add(new ApiMiddleware($this->config));
// Routes
$this->app->get($this->config['prefix'] . '/:resource/:id', [$this, 'getAction'])->conditions(['id' => '\\d+'])->name('resource_get');
$this->app->get($this->config['prefix'] . '/:resource', [$this, 'listAction'])->name('resource_get_list');
$this->app->put($this->config['prefix'] . '/:resource/:id', [$this, 'putAction'])->conditions(['id' => '\\d+'])->name('resource_put');
$this->app->post($this->config['prefix'] . '/:resource', [$this, 'postAction'])->name('resource_post');
$this->app->delete($this->config['prefix'] . '/:resource/:id', [$this, 'deleteAction'])->conditions(['id' => '\\d+'])->name('resource_delete');
}
示例2: slimSetup
public static function slimSetup(\Slim\Slim &$slim, One_Scheme $scheme)
{
//TODO: read specs from behaviour options or from a file
$opt = $scheme->get('behaviorOptions.restable');
$route = $opt['route'];
// retrieve
$slim->get("/{$route}", function () use($scheme) {
One_Controller_Rest::restGetAll($scheme);
});
// retrieve one
$slim->get("/{$route}/:idOrAlias", function ($idOrAlias) use($scheme) {
One_Controller_Rest::restGet($scheme, $idOrAlias);
});
// create new
$slim->post("/{$route}", function () use($scheme) {
One_Controller_Rest::restPost($scheme);
});
// update existing
$slim->put("/{$route}/:idOrAlias", function ($idOrAlias) use($scheme) {
One_Controller_Rest::restPut($scheme, $idOrAlias);
});
// delete existing
$slim->delete("/{$route}/:idOrAlias", function ($idOrAlias) use($scheme) {
One_Controller_Rest::restDelete($scheme, $idOrAlias);
});
}
示例3: addRoutesFromMeta
private function addRoutesFromMeta(Slim $application, ClassMetadata $meta, Controller $controller)
{
$entitiesRoute = $this->getEntitiesRoute($meta);
// Fetch entities route
$application->get($entitiesRoute, function () use($meta, $controller) {
$controller->getEntities($meta);
});
// Create entity
$application->post($entitiesRoute, function () use($meta, $controller) {
$controller->createEntity($meta);
});
$entityRoute = $this->getEntityRoute($meta, $entitiesRoute);
// Get entity
$application->get($entityRoute, function () use($meta, $controller) {
$controller->getEntity($meta, func_get_args());
});
// Update entity
$application->put($entityRoute, function () use($meta, $controller) {
$controller->updateEntity($meta, func_get_args());
});
// Patch entity
$application->patch($entityRoute, function () use($meta, $controller) {
$controller->patchEntity($meta, func_get_args());
});
// Delete entity
$application->delete($entityRoute, function () use($meta, $controller) {
$controller->deleteEntity($meta, func_get_args());
});
// Handling associated entities
foreach ($meta->getAssociationMappings() as $aName => $aData) {
$aTargetClass = $meta->getAssociationTargetClass($aName);
$aMeta = $this->getEntityMeta($aTargetClass);
$aEntitiesRoute = $entityRoute . '/' . $aName;
// Create associated entity
// allow to create entity and link source together
// POST /articles/1/tags will fetch article 1, create tag entity and
// associate it to article 1
$application->post($aEntitiesRoute, function () use($meta, $aMeta, $controller, $aData) {
$controller->createEntity($aMeta, $aData['fieldName'], $meta, func_get_args());
});
// List associated entities
$application->get($aEntitiesRoute, function () use($meta, $controller, $aData) {
$controller->getAssociatedEntities($aData['fieldName'], $meta, func_get_args());
});
// Associate two entities
// POST /articles/1/tags/2 will associate article 1 to tag 2
$aEntityRoute = $this->getEntityRoute($aMeta, $aEntitiesRoute);
$application->post($aEntityRoute, function () use($meta, $aMeta, $controller, $aData) {
$controller->associateEntities($aMeta, $aData['fieldName'], $meta, func_get_args());
});
}
return $application;
}
示例4: _initRoutes
private function _initRoutes()
{
$this->_slim->contentType('application/json');
$this->_slim->get('/basket/', array($this, 'getBaskets'));
$this->_slim->get('/product/', array($this, 'getProducts'));
$this->_slim->get('/basket/:id', array($this, 'getBasket'));
$this->_slim->get('/basket/:id/item/', array($this, 'getBasketItems'));
$this->_slim->get('/basket/:id/item/:prodId', array($this, 'getBasketItem'));
$this->_slim->post('/basket/:id/item/', array($this, 'postBasketItem'));
$this->_slim->put('/basket/:id/item/:prodId', array($this, 'putBasketItem'));
$this->_slim->delete('/basket/:id/item/:prodId', array($this, 'deleteBasketItem'));
}
示例5: routes
function routes(\Slim\Slim $app)
{
$base = $this->getBasePath();
$app->post($base . '/posts/search', function () use($app) {
$app->Posts->search();
});
$app->post($base . '/posts/:id', function ($id) use($app) {
$app->Posts->getById($id);
});
$app->get($base . '/posts/:id', function ($id) use($app) {
$app->Posts->getById($id);
});
$app->post($base . '/posts', function () use($app) {
$app->Posts->save();
});
$app->delete($base . '/posts/:id', function ($id) use($app) {
$app->Posts->delete($id);
});
}
示例6: loadMethodAnnotations
private function loadMethodAnnotations(Slim $app, \ReflectionMethod $method, $newInstanceClass, $uri)
{
$methodAnnotations = $this->getMethodAnnotations($method);
$uriMethod = '';
if (isset($methodAnnotations['SlimAnnotation\\Mapping\\Annotation\\Path'])) {
$uriMethod = $methodAnnotations['SlimAnnotation\\Mapping\\Annotation\\Path']->uri;
}
$uri = $this->normalizeURI($uri, $uriMethod);
if (isset($methodAnnotations['SlimAnnotation\\Mapping\\Annotation\\POST'])) {
$app->post($uri, $method->invoke($newInstanceClass));
}
if (isset($methodAnnotations['SlimAnnotation\\Mapping\\Annotation\\GET'])) {
$app->get($uri, $method->invoke($newInstanceClass));
}
if (isset($methodAnnotations['SlimAnnotation\\Mapping\\Annotation\\DELETE'])) {
$app->delete($uri, $method->invoke($newInstanceClass));
}
if (isset($methodAnnotations['SlimAnnotation\\Mapping\\Annotation\\PUT'])) {
$app->put($uri, $method->invoke($newInstanceClass));
}
}
示例7: function
$news->worker('get_post', $id);
});
$app->get('/news/edit/:id', function ($id) {
require '../news/news.worker.php';
$news = new news();
$news->worker('edit_post', $id);
});
$app->put('/news/edit/:id', function () {
require '../news/news.worker.php';
$data = json_decode(Slim::getInstance()->request()->getBody(), true);
$news = new news();
$news->worker('save_edit', $data);
});
$app->delete('/news/:id', function ($id) {
require '../news/news.worker.php';
$news = new news();
$news->worker('delete_post', $id);
});
$app->get('/featured', function () {
require '../news/news.worker.php';
$news = new news();
$news->worker('featured');
});
// //////////////////////////////
// Forum
// Get Categories
$app->get('/forum/cat', function () {
require '../forum/forum.worker.php';
$forum = new forum();
$forum->worker('get_categories');
});
示例8: getSession
<?php
/*
Author - Diego Alejandro Ramirez
Contact - darasat@gmail.com
*/
require 'Slim/Slim.php';
use Slim\Slim;
Slim::registerAutoloader();
$app = new Slim();
$app->get('/session', 'getSession');
$app->get('/getPhotos', 'getPhotos');
$app->get('/getPhoto/:id', 'getPhoto');
$app->post('/addPhoto', 'addPhoto');
$app->put('/updatePhoto/:id', 'updatePhoto');
$app->delete('/deletePhoto/:id', 'deletePhoto');
$app->run();
// Get Database Connection
function getSession()
{
$db = new DB_Connection();
}
function DB_Connection()
{
$dbhost = "127.0.0.1";
$dbuser = "root";
$dbpass = "";
$dbname = "ino";
$dbh = new PDO("mysql:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $dbh;
示例9: getExploration
require 'config.php';
require 'Slim/Slim.php';
require 'BasicAuth.php';
use Slim\Slim;
use Slim\Extras\Middleware\HttpBasicAuth;
Slim::registerAutoloader();
$app = new Slim();
if (USE_ADMIN_LOGIN) {
$app->add(new BasicAuth(ADMIN_USERNAME, ADMIN_PASSWORD, 'private', array(new Route('DELETE', '/records'), new Route('DELETE', '/explorations'), new Route('PUT', '/explorations'), new Route('POST', '/explorations'))));
}
//exploration routes
$app->get('/explorations/', 'listExplorations');
$app->get('/explorations/:id', 'getExploration');
$app->put('/explorations/:id', 'saveExploration');
$app->post('/explorations/', 'saveExploration');
$app->delete('/explorations/:id', 'deleteExploration');
//record routes
$app->get('/records/:arg', 'getRecord');
$app->get('/records/', function () use($app) {
$req = $app->request->params('exploration_id');
getRecords($req);
});
$app->delete('/records/:arg', 'deleteRecord');
//upload record routes
$app->post('/records/submit/', 'submitRecord');
$app->post('/records/upload/', 'uploadRecordFile');
$app->run();
/* Exploration Methods */
function getExploration($arg)
{
try {
示例10: array
$following = UserService::following($_SESSION['username']);
$unfollowUrl = $app->urlFor('social-unfollow', array('userToUnfollow' => null));
$return = array();
foreach ($following as $friend) {
$content = array_merge(array('unfollowUrl' => $unfollowUrl), $friend->toArray());
$return[] = $app->view->getInstance()->render('graphs/social/friends-partial', $content);
}
$app->jsonResponse->build(array('following' => $return));
})->name('social-follow');
// takes current user session and will unfollow :username
$app->delete('/unfollow/:userToUnfollow', function ($userToUnfollow) use($app) {
UserService::unfollowUser($_SESSION['username'], $userToUnfollow);
$following = UserService::following($_SESSION['username']);
$unfollowUrl = $app->urlFor('social-unfollow', array('userToUnfollow' => null));
$return = array();
foreach ($following as $friend) {
$content = array_merge(array('unfollowUrl' => $unfollowUrl), $friend->toArray());
$return[] = $app->view->getInstance()->render('graphs/social/friends-partial', $content);
}
$app->jsonResponse->build(array('following' => $return));
})->name('social-unfollow');
//search users by name
$app->get('/searchbyusername/:search', function ($search) use($app) {
$users = UserService::searchByUsername($search, $_SESSION['username']);
$app->jsonResponse->build(array('users' => $users));
})->name('user-search');
// social - show posts
$app->get('/posts', $isLoggedIn, function () use($app) {
$content = ContentService::getContent($_SESSION['username'], 0);
$socialContent = array_slice($content, 0, 3);
$moreContent = count($content) >= 4;
示例11: dirname
require_once dirname(__FILE__) . '/Implementacion/Cargo.php';
require_once dirname(__FILE__) . '/Implementacion/Tarjeta.php';
require_once dirname(__FILE__) . '/Implementacion/Cliente.php';
require_once dirname(__FILE__) . '/Implementacion/Plan.php';
use Slim\Slim;
Slim::registerAutoloader();
$app = new Slim(array('debug' => true, 'log.level' => \Slim\Log::DEBUG, 'log.enabled' => true, 'log.writer' => new \Slim\LogWriter(fopen(dirname(__FILE__) . '/log/' . date('Y-M-d') . '.log', 'a'))));
$app->get('/v1/monetizador/test', "ping");
//Cargos
$app->get('/v1/monetizador/cargos', "cargos");
$app->post('/v1/monetizador/cargos', "cargos");
$app->post('/v1/monetizador/cargos/clientes:/id', "cargos");
//Tarjetas
$app->get('/v1/monetizador/tarjetas', "cards");
$app->post('/v1/monetizador/tarjetas', "cardAdd");
$app->delete("/v1/monetizador/tarjetas/:id", "cardDelete");
// Cliente
$app->post("/v1/monetizador/clientes", "cliente");
$app->get("/v1/monetizador/clientes", "clienteListar");
$app->get("/v1/monetizador/clientes/:id", "clienteListar");
$app->delete("/v1/monetizador/clientes/:id", "clienteEliminar");
$app->put("/v1/monetizador/clientes/:id", "clienteEditar");
// Cliente - Tarjeta
$app->post('/v1/monetizador/tarjetas/clientes/:id', "cardAdd");
$app->get('/v1/monetizador/tarjetas/clientes/:id', "cards");
$app->delete("/v1/monetizador/clientes/:idcliente/tarjetas/:id", "cardDelete");
// Plan
$app->post("/v1/monetizador/planes", "plan");
$app->get("/v1/monetizador/planes", "clienteListar");
$app->get("/v1/monetizador/planes/:id", "clienteListar");
$app->delete("/v1/monetizador/planes/:id", "clienteEliminar");
示例12: OdaPrepareInterface
$params = new OdaPrepareInterface();
$params->arrayInput = array("teamA", "colorA", "teamB", "colorB");
$params->modePublic = false;
$params->slim = $slim;
$INTERFACE = new MatchInterface($params);
$INTERFACE->create();
});
$slim->get('/match/:id/report/recap/', function ($id) use($slim) {
$params = new OdaPrepareInterface();
$params->slim = $slim;
$INTERFACE = new MatchInterface($params);
$INTERFACE->getRecapForMatch($id);
});
$slim->post('/match/event/', function () use($slim) {
$params = new OdaPrepareInterface();
$params->arrayInput = array("matchId", "team");
$params->arrayInputOpt = array("twoMissing" => 0, "twoSuccess" => 0, "treeMissing" => 0, "treeSuccess" => 0, "oneMissing" => 0, "oneSuccess" => 0, "fault" => 0);
$params->modePublic = false;
$params->slim = $slim;
$INTERFACE = new MatchInterface($params);
$INTERFACE->createEvent();
});
$slim->delete('/match/:id/event/', function ($id) use($slim) {
$params = new OdaPrepareInterface();
$params->modePublic = false;
$params->slim = $slim;
$INTERFACE = new MatchInterface($params);
$INTERFACE->undoEvent($id);
});
//--------------------------------------------------------------------------
$slim->run();
示例13:
$app->get('/logout', 'logout');
// Logout
// Backend
// User section routes
// user Dashboard
$app->get('/dashboard/user/:id', 'showAccount');
// Show the account information
$app->get('/dashboard/user_details/:id', 'showDetails');
// Show user Details
$app->put('/dashboard/update/:id', 'updateDetails');
// Update user Details
$app->put('/dashboard/account_type/:id', 'updateAccountType');
// Update user Details
$app->put('/dashboard/account_pass/:id', 'updateAccountPass');
// Update user Details
$app->delete('/dashboard/update/:id', 'deleteDetails');
// Delete user Details
$app->get('/dashboard/user_deposit/:id', 'deposit');
// Show the Deposit Page
$app->put('/dashboard/deposit/:id', 'updateDeposit');
// Route to accept the Deposit form
$app->get('/dashboard/user_withdrawal/:id', 'withdrawal');
// Show the Withdrawal Page
$app->put('/dashboard/withdrawal/:id', 'updateWithdrawal');
// Route to accept the Withdrawal form
$app->get('/dashboard/user_history/:id', 'history');
// Show the History page
// Admin section routes
$app->get('/dashboard/admin/:id', 'listAccounts');
// Show the account information
$app->get('/dashboard/add_account/:id', 'addAccount');
示例14: function
$app->get('/contacts/:id', $contentNegotiation, function ($id) use($app) {
//This value should be specific to the current resource
$lastModifiedTime = gmdate('D, d M Y H:i:s ') . ' GMT';
$app->response()->header('Last-Modified', $lastModifiedTime);
$app->status(200);
echo $app->render($app->template, ['contact' => ['contact_id' => $id, 'name' => $app->faker->firstName, 'last_name' => $app->faker->lastName]]);
});
$app->put('/contacts/:id', $contentNegotiation, function ($id) use($app) {
$contactInformation = $app->request()->getBody();
parse_str($contactInformation, $contact);
$contact['contact_id'] = $id;
if (empty($contact['name'])) {
$contact['name'] = $app->faker->firstName;
}
if (empty($contact['last_name'])) {
$contact['last_name'] = $app->faker->lastName;
}
$lastModifiedTime = time();
$app->lastModified($lastModifiedTime);
$app->status(200);
echo $app->render($app->template, ['contact' => $contact]);
});
$app->delete('/contacts/:id', function ($id) use($app) {
//Delete contact here
$app->status(204);
});
$app->options('/contacts/:id', function ($id) use($app) {
$validOptions = ['GET', 'HEAD', 'PUT', 'DELETE', 'OPTIONS'];
$app->response()->header('Allow', implode(',', $validOptions));
});
$app->run();
示例15: function
}
});
// Put
$app->put('/:resource(/(:action)(/))', function ($resource, $subResource = null) use($app) {
$resource = Resource::load($app->version, $resource, $subResource);
if ($resource === null) {
Resource::error(Resource::STATUS_NOT_FOUND, 'Cannot find requested resource.');
} else {
$resource->put();
}
});
// Delete
$app->delete('/:resource(/(:action)(/))', function ($resource, $subResource = null) use($app) {
$resource = Resource::load($app->version, $resource, $subResource);
if ($resource === null) {
Resource::error(Resource::STATUS_NOT_FOUND, 'Cannot find requested resource.');
} else {
$resource->delete();
}
});
// Options
$app->options('/:resource(/(:action)(/))', function ($resource, $subResource = null) use($app) {
$resource = Resource::load($app->version, $resource, $subResource);
if ($resource === null) {
Resource::error(Resource::STATUS_NOT_FOUND, 'Cannot find requested resource.');
} else {
$resource->options();
}
});
// Not found
$app->notFound(function () {
Resource::error(Resource::STATUS_NOT_FOUND, 'Cannot find requested resource.');