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


PHP Application::patch方法代码示例

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


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

示例1: createResource

 /**
  * Create a resource and all its sub-resources.
  *
  * @param array $resourceConfig
  * @param array $parentUris
  * @throws \RuntimeException
  */
 public function createResource(array $resourceConfig, array $parentUris = array())
 {
     if (empty($resourceConfig['uri']) || empty($resourceConfig['ctl'])) {
         throw new \RuntimeException('Invalid resource config encountered. Config must contain uri and ctl keys');
     }
     if ($resourceConfig['ctl'] instanceof \Closure) {
         //registers controller factory inline
         $controllerName = $this->registerController($resourceConfig['uri'], $resourceConfig['ctl'], $parentUris);
     } elseif (is_string($resourceConfig['ctl'])) {
         $controllerName = $resourceConfig['ctl'];
     } else {
         throw new \RuntimeException('Ctl must be a factory (Closure) or existing service (string name)');
     }
     //setup routes
     $this->app->get($this->createRouteUri($resourceConfig['uri'], $parentUris, true), sprintf('%s:get', $controllerName));
     $this->app->get($this->createRouteUri($resourceConfig['uri'], $parentUris, false), sprintf('%s:cget', $controllerName));
     $this->app->post($this->createRouteUri($resourceConfig['uri'], $parentUris, false), sprintf('%s:post', $controllerName));
     $this->app->put($this->createRouteUri($resourceConfig['uri'], $parentUris, true), sprintf('%s:put', $controllerName));
     $this->app->patch($this->createRouteUri($resourceConfig['uri'], $parentUris, true), sprintf('%s:patch', $controllerName));
     $this->app->delete($this->createRouteUri($resourceConfig['uri'], $parentUris, true), sprintf('%s:delete', $controllerName));
     //handle sub resources
     if (!empty($resourceConfig['sub'])) {
         if (!is_array($resourceConfig['sub'])) {
             throw new \RuntimeException('sub config must contain array of sub resources');
         }
         //append current uri as parent
         $parentUris[] = $resourceConfig['uri'];
         foreach ($resourceConfig['sub'] as $subResource) {
             $this->createResource($subResource, $parentUris);
         }
     }
 }
开发者ID:warmans,项目名称:silex-rest-provider,代码行数:39,代码来源:RestService.php

示例2: testMatchReturnValue

 public function testMatchReturnValue()
 {
     $app = new Application();
     $returnValue = $app->match('/foo', function () {
     });
     $this->assertInstanceOf('Silex\\Controller', $returnValue);
     $returnValue = $app->get('/foo', function () {
     });
     $this->assertInstanceOf('Silex\\Controller', $returnValue);
     $returnValue = $app->post('/foo', function () {
     });
     $this->assertInstanceOf('Silex\\Controller', $returnValue);
     $returnValue = $app->put('/foo', function () {
     });
     $this->assertInstanceOf('Silex\\Controller', $returnValue);
     $returnValue = $app->patch('/foo', function () {
     });
     $this->assertInstanceOf('Silex\\Controller', $returnValue);
     $returnValue = $app->delete('/foo', function () {
     });
     $this->assertInstanceOf('Silex\\Controller', $returnValue);
 }
开发者ID:jeanpimentel,项目名称:slack-invitation,代码行数:22,代码来源:ApplicationTest.php

示例3: testMethodRouting

 public function testMethodRouting()
 {
     $app = new Application();
     $app->match('/foo', function () {
         return 'foo';
     });
     $app->match('/bar', function () {
         return 'bar';
     })->method('GET|POST');
     $app->get('/resource', function () {
         return 'get resource';
     });
     $app->post('/resource', function () {
         return 'post resource';
     });
     $app->put('/resource', function () {
         return 'put resource';
     });
     $app->patch('/resource', function () {
         return 'patch resource';
     });
     $app->delete('/resource', function () {
         return 'delete resource';
     });
     $this->checkRouteResponse($app, '/foo', 'foo');
     $this->checkRouteResponse($app, '/bar', 'bar');
     $this->checkRouteResponse($app, '/bar', 'bar', 'post');
     $this->checkRouteResponse($app, '/resource', 'get resource');
     $this->checkRouteResponse($app, '/resource', 'post resource', 'post');
     $this->checkRouteResponse($app, '/resource', 'put resource', 'put');
     $this->checkRouteResponse($app, '/resource', 'patch resource', 'patch');
     $this->checkRouteResponse($app, '/resource', 'delete resource', 'delete');
 }
开发者ID:t-web,项目名称:Silex,代码行数:33,代码来源:RouterTest.php

示例4: function

$app['collection.service'] = function () use($app) {
    return new CollectionService($app['resource.service'], $app['triplestore'], $app['fedora']);
};
$app['collection.controller'] = function () use($app) {
    return new CollectionController($app['collection.service']);
};
$app['transaction.service'] = function () use($app) {
    return new TransactionService($app['fedora']);
};
$app['transaction.controller'] = function () use($app) {
    return new TransactionController($app['transaction.service']);
};
$app->get('islandora/resource/{id}', 'resource.controller:find');
$app->post('islandora/resource/', 'resource.controller:create');
$app->put('islandora/resource/{id}', 'resource.controller:upsert');
$app->patch('islandora/resource/{id}', 'resource.controller:sparqlUpdate');
$app->delete('islandora/resource/{id}', 'resource.controller:delete');
$app->get('islandora/transaction/{id}', 'transaction.controller:status');
$app->post('islandora/transaction/', 'transaction.controller:create');
$app->post('islandora/transaction/{id}', 'transaction.controller:extend');
$app->post('islandora/transaction/{id}/commit', 'transaction.controller:commit');
$app->post('islandora/transaction/{id}/rollback', 'transaction.controller:rollback');
//$app->get('islandora/members/{id}', 'members.controller:find');
//$app->post('islandora/members/{id}/{child_id}', 'members.controller:add');
//$app->delete('islandora/members/{id}/{child_id}', 'members.controller:remove');
//$app->patch('islandora/members/{id}/{child_id}/{destination_id}', 'members.controller:migrate');
$app->get('islandora/collection/', 'collection.controller:index');
$app->post('islandora/collection/', 'collection.controller:create');
//$app->get('islandora/files/{id}', 'files.controller:find');
//$app->post('islandora/files/{id}/{child_id}', 'files.controller:add');
//$app->delete('islandora/files/{id}/{child_id}', 'files.controller:remove');
开发者ID:daniel-dgi,项目名称:silexTest,代码行数:31,代码来源:index.php

示例5: patch

 /**
  * @param string $pattern
  * @param Endpoint $to
  * @return \Silex\Controller
  */
 public function patch($pattern, $to = null)
 {
     return parent::patch($pattern, $to);
 }
开发者ID:clearbooks,项目名称:dilex,代码行数:9,代码来源:Dilex.php


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