Skip to content

Commit eb10901

Browse files
committed
Merge branch '1.8'
Conflicts: DependencyInjection/FOSRestExtension.php Resources/config/view.xml Resources/doc/5-automatic-route-generation_single-restful-controller.rst Routing/Loader/Reader/RestActionReader.php Routing/Loader/RestRouteLoader.php Tests/DependencyInjection/FOSRestExtensionTest.php Tests/Fixtures/Controller/AnnotatedUsersController.php Tests/Fixtures/Controller/OrdersController.php Tests/Fixtures/Controller/UsersController.php Tests/Fixtures/Etalon/annotated_users_controller.yml Tests/Fixtures/Etalon/users_controller.yml composer.json
2 parents 40c2044 + d6cbe3d commit eb10901

File tree

9 files changed

+31
-73
lines changed

9 files changed

+31
-73
lines changed

DependencyInjection/FOSRestExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private function loadAccessDeniedListener(array $config, XmlFileLoader $loader,
9292
$service = $container->getDefinition('fos_rest.access_denied_listener');
9393

9494
if (!empty($config['access_denied_listener']['service'])) {
95-
$service->clearTag('kernel.event_listener');
95+
$service->clearTag('kernel.event_subscriber');
9696
}
9797

9898
$service->replaceArgument(0, $config['access_denied_listener']['formats']);
@@ -323,7 +323,7 @@ private function loadException(array $config, XmlFileLoader $loader, ContainerBu
323323

324324
if (!empty($config['exception']['service'])) {
325325
$service = $container->getDefinition('fos_rest.exception_listener');
326-
$service->clearTag('kernel.event_listener');
326+
$service->clearTag('kernel.event_subscriber');
327327
}
328328

329329
if ($config['exception']['exception_controller']) {

Routing/Loader/DirectoryRouteLoader.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace FOS\RestBundle\Routing\Loader;
1313

1414
use Symfony\Component\Config\Loader\Loader;
15+
use Symfony\Component\Finder\Finder;
1516
use Symfony\Component\Routing\RouteCollection;
1617

1718
/**
@@ -39,14 +40,10 @@ public function load($resource, $type = null)
3940

4041
$collection = new RouteCollection();
4142

42-
$directoryIterator = new \DirectoryIterator($resource);
43+
$finder = new Finder();
4344

44-
foreach ($directoryIterator as $file) {
45-
if ($file->getFilename() === '.' || $file->getFilename() === '..') {
46-
continue;
47-
}
48-
49-
$imported = $this->processor->importResource($this, ClassUtils::findClassInFile($file->getPathname()), array(), null, null, 'rest');
45+
foreach ($finder->in($resource)->name('*.php')->files() as $file) {
46+
$imported = $this->processor->importResource($this, ClassUtils::findClassInFile($file), array(), null, null, 'rest');
5047
$collection->addCollection($imported);
5148
}
5249

Tests/Fixtures/Controller/AnnotatedUsersController.php

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
class AnnotatedUsersController extends Controller
3535
{
3636
/**
37-
* [OPTIONS] /users.
37+
* @Options
3838
*/
3939
public function optionsUsersAction()
4040
{
@@ -64,64 +64,40 @@ public function propfindUserPropsAction($id, $property)
6464
}
6565

6666
/**
67-
* [PROPPATCH] /users/{id}/props/{property}.
68-
*
69-
* @param $id
70-
* @param $property
71-
*
7267
* @PropPatch()
7368
*/
7469
public function proppatchUserPropsAction($id, $property)
7570
{
7671
}
7772

7873
/**
79-
* [MOVE] /users/{id}.
80-
*
81-
* @param $id
82-
*
8374
* @Move()
8475
*/
8576
public function moveUserAction($id)
8677
{
8778
}
8879

8980
/**
90-
* [MKCOL] /users.
91-
*
9281
* @Mkcol()
9382
*/
9483
public function mkcolUsersAction()
9584
{
9685
}
9786

9887
/**
99-
* [LOCK] /users/{slug}.
100-
*
101-
* @param $slug
102-
*
10388
* @Lock()
10489
*/
10590
public function lockUserAction($slug)
10691
{
10792
}
10893

10994
/**
110-
* [UNLOCK] /users/{slug}.
111-
*
112-
* @param $slug
113-
*
11495
* @Unlock()
11596
*/
11697
public function unlockUserAction($slug)
11798
{
11899
}
119100

120-
/**
121-
* [OPTIONS] /users.
122-
*
123-
* @Options
124-
*/
125101
public function boptionsUsersAction()
126102
{
127103
}

Tests/Fixtures/Controller/OrdersController.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,18 @@ class OrdersController extends Controller
1717
{
1818
// conventional HATEOAS action after REST action
1919

20-
/**
21-
* [GET] /foos/new.
22-
*/
2320
public function newFoosAction()
2421
{
2522
}
2623

27-
/**
28-
* [GET] /foos.
29-
*/
24+
// [GET] /foos/new
25+
3026
public function getFoosAction()
3127
{
3228
}
3329

30+
// [GET] /foos
31+
3432
// conventional HATEOAS action before REST action
3533

3634
/**

Tests/Fixtures/Controller/UsersController.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616

1717
class UsersController extends Controller
1818
{
19-
/**
20-
* [COPY] /users/{id}.
21-
*
22-
* @param $id
23-
*/
2419
public function copyUserAction($id)
2520
{
2621
}
@@ -125,20 +120,12 @@ public function lockUserAction($slug)
125120
{
126121
}
127122

128-
/**
129-
* [UNLOCK] /users/{slug}.
130-
*
131-
* @param $slug
132-
*/
133123
public function unlockUserAction($slug)
134124
{
135125
}
136126

137-
/**
138-
* [GET] /users/{slug}/comments.
139-
*
140-
* @param $slug
141-
*/
127+
// [PATCH] /users/{slug}/unlock
128+
142129
public function getUserCommentsAction($slug)
143130
{
144131
}

Tests/Fixtures/Etalon/annotated_users_controller.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
copy_user:
2-
methods: [COPY]
3-
path: /users/{id}.{_format}
2+
methods: [COPY]
3+
path: /users/{id}.{_format}
44
controller: ::copyUserAction
55

66
propfind_user_props:
@@ -24,13 +24,13 @@ mkcol_users:
2424
controller: ::mkcolUsersAction
2525

2626
lock_user:
27-
methods: [LOCK]
28-
path: /users/{slug}.{_format}
27+
methods: [LOCK]
28+
path: /users/{slug}.{_format}
2929
controller: ::lockUserAction
3030

3131
unlock_user:
32-
methods: [UNLOCK]
33-
path: /users/{slug}.{_format}
32+
methods: [UNLOCK]
33+
path: /users/{slug}.{_format}
3434
controller: ::unlockUserAction
3535

3636
get_users:

Tests/Fixtures/Etalon/users_controller.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ lock_user:
5959
controller: ::lockUserAction
6060

6161
unlock_user:
62-
methods: [UNLOCK]
63-
path: /users/{slug}.{_format}
62+
methods: [UNLOCK]
63+
path: /users/{slug}.{_format}
6464
controller: ::unlockUserAction
6565

6666
get_user_comments:

Tests/Routing/Loader/DirectoryRouteLoaderTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,9 @@ public function testLoad()
2323

2424
$this->assertCount(9, $collection);
2525

26-
$this->assertInstanceOf('Symfony\Component\Routing\Route', $collection->get('get_users'));
27-
$this->assertInstanceOf('Symfony\Component\Routing\Route', $collection->get('get_user'));
28-
$this->assertInstanceOf('Symfony\Component\Routing\Route', $collection->get('post_users'));
29-
$this->assertInstanceOf('Symfony\Component\Routing\Route', $collection->get('put_user'));
30-
$this->assertInstanceOf('Symfony\Component\Routing\Route', $collection->get('get_comments'));
31-
$this->assertInstanceOf('Symfony\Component\Routing\Route', $collection->get('put_comment'));
32-
$this->assertInstanceOf('Symfony\Component\Routing\Route', $collection->get('get_topics'));
33-
$this->assertInstanceOf('Symfony\Component\Routing\Route', $collection->get('get_topic'));
34-
$this->assertInstanceOf('Symfony\Component\Routing\Route', $collection->get('put_topic'));
26+
foreach ($collection as $route) {
27+
$this->assertInstanceOf('Symfony\Component\Routing\Route', $route);
28+
}
3529
}
3630

3731
/**

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@
2424
"php": "^5.5.9|~7.0",
2525
"psr/log": "^1.0",
2626
"symfony/framework-bundle": "^2.7|^3.0",
27+
"symfony/finder": "^2.7|^3.0",
2728
"symfony/routing": "^2.7|^3.0",
2829
"doctrine/inflector": "^1.0",
2930
"willdurand/negotiation": "^2.0",
3031
"willdurand/jsonp-callback-validator": "^1.0"
3132
},
3233

3334
"require-dev": {
34-
"sensio/framework-extra-bundle": "^3.0",
35+
"sensio/framework-extra-bundle": "^3.0.13",
3536
"symfony/phpunit-bridge": "~2.7|^3.0",
3637
"symfony/form": "^2.7|^3.0",
3738
"symfony/validator": "^2.7|^3.0",
@@ -63,6 +64,11 @@
6364
}
6465
},
6566

67+
"conflict": {
68+
"sensio/framework-extra-bundle": "<3.0.13"
69+
},
70+
71+
6672
"extra": {
6773
"branch-alias": {
6874
"dev-master": "2.0-dev"

0 commit comments

Comments
 (0)