forked from FriendsOfSymfony/FOSRestBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do not overwrite explicit templates, fix issues with redirects
- Loading branch information
Showing
8 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
Tests/Functional/Bundle/TestBundle/Controller/ArticleController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the FOSRestBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\RestBundle\Tests\Functional\Bundle\TestBundle\Controller; | ||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
use FOS\RestBundle\Controller\Annotations\RouteResource; | ||
use FOS\RestBundle\Controller\Annotations\View; | ||
use FOS\RestBundle\Controller\FOSRestController; | ||
|
||
/** | ||
* @RouteResource("Article") | ||
*/ | ||
class ArticleController extends FOSRestController | ||
{ | ||
/** | ||
* Get list. | ||
* | ||
* @param Request $request | ||
* | ||
* @return View view instance | ||
* | ||
* @View() | ||
*/ | ||
public function cgetAction(Request $request) | ||
{ | ||
$view = $this->view(); | ||
$view->setTemplate('TestBundle:Article:foo.html.twig'); | ||
|
||
return $view; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Tests/Functional/Bundle/TestBundle/Resources/views/Article/foo.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fooo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the FOSRestBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\RestBundle\Tests\Functional; | ||
|
||
class ViewResponseListenerTest extends WebTestCase | ||
{ | ||
public function testTemplateOverride() | ||
{ | ||
$client = $this->createClient(array('test_case' => 'ViewResponseListener')); | ||
$client->request( | ||
'GET', | ||
'/articles' | ||
); | ||
|
||
$this->assertSame(200, $client->getResponse()->getStatusCode()); | ||
$this->assertContains('fooo', $client->getResponse()->getContent()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the FOSRestBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
return array( | ||
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), | ||
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), | ||
new \FOS\RestBundle\FOSRestBundle(), | ||
new \FOS\RestBundle\Tests\Functional\Bundle\TestBundle\TestBundle(), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
imports: | ||
- { resource: ../config/default.yml } | ||
|
||
framework: | ||
serializer: | ||
enabled: true | ||
|
||
fos_rest: | ||
view: | ||
view_response_listener: 'force' | ||
formats: | ||
xml: true | ||
json: true | ||
templating_formats: | ||
html: true | ||
format_listener: | ||
rules: | ||
- { path: ^/, priorities: [ html, json, xml ], fallback_format: ~, prefer_extension: true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters