Skip to content

Commit b9b4086

Browse files
committed
Merge remote-tracking branch 'upstream/2.4' into techtalk
# By Fabien Potencier (22) and others # Via Fabien Potencier * upstream/2.4: (31 commits) bumped 2.4 to stable updated VENDORS for 2.4.0-RC1 updated to FrameworkExtraBundle 3.0 (examples updated as well) backported symfony#585 Backport issue 426 / PR 429 to branch 2.2 Added config to force Symfony to use native session handler by default updated VENDORS for 2.2.10 updated VENDORS for 2.4.0-BETA2 updated VENDORS for 2.2.9 updated min stability to beta updated VENDORS for 2.4.0-BETA1 fixed CS Refactored contact action to use new form methods in 2.3 updated VENDORS for 2.2.8 Revert "merged branch eventhorizonpl/fix_doctrine_common_dependency (PR symfony#591)" Added comment about http_method_override and HttpCache fix doctrine-common dependency for 2.3 version added some functional tests for the secure section of the demo bundle updated VENDORS for 2.3.4 updated VENDORS for 2.2.6 ... Conflicts: app/SymfonyRequirements.php app/autoload.php app/config/config.yml src/Acme/DemoBundle/Controller/DemoController.php
2 parents e803e6b + 1d2e912 commit b9b4086

File tree

17 files changed

+118
-96
lines changed

17 files changed

+118
-96
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/app/cache/*
33
/app/config/parameters.yml
44
/app/logs/*
5+
!app/cache/.gitkeep
6+
!app/logs/.gitkeep
57
/build/
68
/vendor/
79
/bin/

UPGRADE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ a link cannot be generated):
7979

8080
framework:
8181
router:
82-
strict_requirements: %kernel.debug%
82+
strict_requirements: "%kernel.debug%"
8383

8484
You can even disable the requirements check on production with `null` as you should
8585
know that the parameters for URL generation always pass the requirements, e.g. by
@@ -90,7 +90,7 @@ The `default_locale` parameter is now a setting of the main `framework`
9090
configuration (it was under the `framework.session` in 2.0):
9191

9292
framework:
93-
default_locale: %locale%
93+
default_locale: "%locale%"
9494

9595
The `auto_start` setting under `framework.session` must be removed as it is
9696
not used anymore (the session is now always started on-demand). If

app/SymfonyRequirements.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,6 @@ class_exists('Locale'),
648648
||
649649
(extension_loaded('apc') && ini_get('apc.enabled'))
650650
||
651-
(extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.enable'))
652-
||
653651
(extension_loaded('Zend OPcache') && ini_get('opcache.enable'))
654652
||
655653
(extension_loaded('xcache') && ini_get('xcache.cacher'))

app/autoload.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@
1111

1212
use Doctrine\Common\Annotations\AnnotationRegistry;
1313

14-
// intl
15-
if (!function_exists('intl_get_error_code')) {
16-
require_once __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';
17-
18-
$loader->add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs');
19-
}
20-
2114
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
2215
AnnotationRegistry::registerFile(__DIR__.'/../vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/DoctrineAnnotations.php');
16+
17+
return $loader;

app/config/config.yml

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ imports:
44

55
framework:
66
#esi: ~
7-
#translator: { fallback: %locale% }
8-
secret: %secret%
7+
#translator: { fallback: "%locale%" }
8+
secret: "%secret%"
99
router:
1010
resource: "%kernel.root_dir%/config/routing.yml"
1111
strict_requirements: ~
@@ -16,54 +16,57 @@ framework:
1616
engines: ['twig', 'php']
1717
#assets_version: SomeVersionScheme
1818
default_locale: "%locale%"
19+
trusted_hosts: ~
1920
trusted_proxies: ~
20-
session: ~
21+
session:
22+
# handler_id set to null will use default session handler from php.ini
23+
handler_id: ~
2124
fragments: ~
2225
http_method_override: true
2326

2427
# Twig Configuration
2528
twig:
26-
debug: %kernel.debug%
27-
strict_variables: %kernel.debug%
29+
debug: "%kernel.debug%"
30+
strict_variables: "%kernel.debug%"
2831
exception_controller: 'FOS\RestBundle\Controller\ExceptionController::showAction'
2932

3033
# Assetic Configuration
3134
assetic:
32-
debug: %kernel.debug%
35+
debug: "%kernel.debug%"
3336
use_controller: false
3437
bundles: [ LiipHelloBundle ]
3538
#java: /usr/bin/java
3639
filters:
3740
cssrewrite: ~
3841
#closure:
39-
# jar: %kernel.root_dir%/Resources/java/compiler.jar
42+
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
4043
#yui_css:
41-
# jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
44+
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
4245

4346
# Doctrine Configuration
4447
doctrine:
4548
dbal:
46-
driver: %database_driver%
47-
host: %database_host%
48-
port: %database_port%
49-
dbname: %database_name%
50-
user: %database_user%
51-
password: %database_password%
49+
driver: "%database_driver%"
50+
host: "%database_host%"
51+
port: "%database_port%"
52+
dbname: "%database_name%"
53+
user: "%database_user%"
54+
password: "%database_password%"
5255
charset: UTF8
5356
# if using pdo_sqlite as your database driver, add the path in parameters.yml
54-
# e.g. database_path: %kernel.root_dir%/data/data.db3
55-
path: %database_path%
57+
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
58+
path: "%database_path%"
5659

5760
orm:
58-
auto_generate_proxy_classes: %kernel.debug%
61+
auto_generate_proxy_classes: "%kernel.debug%"
5962
auto_mapping: true
6063

6164
# Swiftmailer Configuration
6265
swiftmailer:
63-
transport: %mailer_transport%
64-
host: %mailer_host%
65-
username: %mailer_user%
66-
password: %mailer_password%
66+
transport: "%mailer_transport%"
67+
host: "%mailer_host%"
68+
username: "%mailer_user%"
69+
password: "%mailer_password%"
6770
spool: { type: memory }
6871

6972
fos_user:

app/config/config_dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ monolog:
1515
handlers:
1616
main:
1717
type: stream
18-
path: %kernel.logs_dir%/%kernel.environment%.log
18+
path: "%kernel.logs_dir%/%kernel.environment%.log"
1919
level: debug
2020
#console:
2121
# type: console

app/config/config_prod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ monolog:
1919
handler: nested
2020
nested:
2121
type: stream
22-
path: %kernel.logs_dir%/%kernel.environment%.log
22+
path: "%kernel.logs_dir%/%kernel.environment%.log"
2323
level: debug
2424
#console:
2525
# type: console

app/config/config_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ framework:
66
session:
77
storage_id: session.storage.mock_file
88
profiler:
9-
enabled: false
9+
collect: false
1010

1111
web_profiler:
1212
toolbar: false

app/config/routing.yml

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +0,0 @@
1-
hello:
2-
resource: "@LiipHelloBundle/Resources/config/routing.yml"
3-
4-
security:
5-
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
6-
prefix: /liip
7-
8-
profile:
9-
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
10-
prefix: /liip/profile
11-
12-
registration:
13-
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
14-
prefix: /liip/register
15-
16-
_imagine:
17-
resource: .
18-
type: imagine
19-
20-
NelmioApiDocBundle:
21-
resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
22-
prefix: /api/doc
23-
24-
theme:
25-
resource: "@LiipThemeBundle/Resources/config/routing.xml"
26-
prefix: /liip/theme
27-
28-
monitor:
29-
resource: "@LiipMonitorBundle/Resources/config/routing.yml"
30-
prefix: /liip
31-
32-
fos_facebook_channel:
33-
pattern: /channel.html
34-
defaults: { _controller: "FOSFacebookBundle:Facebook:channel" }

app/config/routing_dev.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,41 @@ _configurator:
1313
_main:
1414
resource: routing.yml
1515

16-
# AcmeDemoBundle routes (to be removed)
16+
# demo routes (to be removed)
1717
_acme_demo:
1818
resource: "@AcmeDemoBundle/Resources/config/routing.yml"
19+
20+
hello:
21+
resource: "@LiipHelloBundle/Resources/config/routing.yml"
22+
23+
security:
24+
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
25+
prefix: /liip
26+
27+
profile:
28+
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
29+
prefix: /liip/profile
30+
31+
registration:
32+
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
33+
prefix: /liip/register
34+
35+
_imagine:
36+
resource: .
37+
type: imagine
38+
39+
NelmioApiDocBundle:
40+
resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
41+
prefix: /api/doc
42+
43+
theme:
44+
resource: "@LiipThemeBundle/Resources/config/routing.xml"
45+
prefix: /liip/theme
46+
47+
monitor:
48+
resource: "@LiipMonitorBundle/Resources/config/routing.yml"
49+
prefix: /liip
50+
51+
fos_facebook_channel:
52+
pattern: /channel.html
53+
defaults: { _controller: "FOSFacebookBundle:Facebook:channel" }

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"symfony/swiftmailer-bundle": "~2.3",
1717
"symfony/monolog-bundle": "~2.3",
1818
"sensio/distribution-bundle": "~2.3",
19-
"sensio/framework-extra-bundle": "~2.3",
19+
"sensio/framework-extra-bundle": "~3.0",
2020
"sensio/generator-bundle": "~2.3",
2121
"incenteev/composer-parameter-handler": "~2.0",
2222
"doctrine/doctrine-fixtures-bundle": "dev-master",
@@ -56,7 +56,6 @@
5656
"config": {
5757
"bin-dir": "bin"
5858
},
59-
"minimum-stability": "dev",
6059
"extra": {
6160
"incenteev-parameters": {
6261
"file": "app/config/parameters.yml"

src/Acme/DemoBundle/Controller/DemoController.php

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
66
use Symfony\Component\HttpFoundation\RedirectResponse;
7+
use Symfony\Component\HttpFoundation\Request;
78
use Acme\DemoBundle\Form\ContactType;
89

910
// these import the "@Route" and "@Template" annotations
@@ -34,29 +35,20 @@ public function helloAction($name)
3435
* @Route("/contact", name="_demo_contact")
3536
* @Template()
3637
*/
37-
public function contactAction()
38+
public function contactAction(Request $request)
3839
{
39-
$form = $this->get('form.factory')->create(new ContactType());
40+
$form = $this->createForm(new ContactType());
41+
$form->handleRequest($request);
4042

41-
$request = $this->get('request');
42-
if ($request->isMethod('POST')) {
43-
$form->submit($request);
44-
if ($form->isValid()) {
45-
$mailer = $this->get('mailer');
46-
// .. setup a message and send it
47-
// http://symfony.com/doc/current/cookbook/email.html
48-
$data = $form->getData();
49-
$message = \Swift_Message::newInstance()
50-
->setSubject('new message')
51-
->setFrom('[email protected]')
52-
->setTo($data['email'])
53-
->setBody($data['message']);
43+
if ($form->isValid()) {
44+
$mailer = $this->get('mailer');
5445

55-
$mailer->send($message);
56-
$this->get('session')->setFlash('notice', 'Message sent!');
46+
// .. setup a message and send it
47+
// http://symfony.com/doc/current/cookbook/email.html
5748

58-
return new RedirectResponse($this->generateUrl('_demo'));
59-
}
49+
$request->getSession()->getFlashBag()->set('notice', 'Message sent!');
50+
51+
return new RedirectResponse($this->generateUrl('_demo'));
6052
}
6153

6254
return array('form' => $form->createView());

src/Acme/DemoBundle/Controller/SecuredController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
88
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
99
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
10+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
1011

1112
/**
1213
* @Route("/demo/secured")

src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,32 @@ public function testIndex()
1414

1515
$this->assertGreaterThan(0, $crawler->filter('html:contains("Hello Fabien")')->count());
1616
}
17+
18+
public function testSecureSection()
19+
{
20+
$client = static::createClient();
21+
22+
// goes to the secure page
23+
$crawler = $client->request('GET', '/demo/secured/hello/World');
24+
25+
// redirects to the login page
26+
$crawler = $client->followRedirect();
27+
28+
// submits the login form
29+
$form = $crawler->selectButton('Login')->form(array('_username' => 'admin', '_password' => 'adminpass'));
30+
$client->submit($form);
31+
32+
// redirect to the original page (but now authenticated)
33+
$crawler = $client->followRedirect();
34+
35+
// check that the page is the right one
36+
$this->assertCount(1, $crawler->filter('h1.title:contains("Hello World!")'));
37+
38+
// click on the secure link
39+
$link = $crawler->selectLink('Hello resource secured')->link();
40+
$crawler = $client->click($link);
41+
42+
// check that the page is the right one
43+
$this->assertCount(1, $crawler->filter('h1.title:contains("secured for Admins only!")'));
44+
}
1745
}

src/Acme/DemoBundle/Twig/Extension/DemoExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function setController($controller)
2525
public function getFunctions()
2626
{
2727
return array(
28-
'code' => new \Twig_Function_Method($this, 'getCode', array('is_safe' => array('html'))),
28+
new \Twig_SimpleFunction('code', array($this, 'getCode'), array('is_safe' => array('html'))),
2929
);
3030
}
3131

web/.htaccess

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Use the front controller as index file. It serves as fallback solution when
1+
# Use the front controller as index file. It serves as a fallback solution when
22
# every other rewrite/redirect fails (e.g. in an aliased environment without
33
# mod_rewrite). Additionally, this reduces the matching process for the
4-
# startpage (path "/") because otherwise Apache will apply the rewritting rules
4+
# start page (path "/") because otherwise Apache will apply the rewriting rules
55
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
66
DirectoryIndex app.php
77

@@ -24,7 +24,7 @@ DirectoryIndex app.php
2424
# endless redirect loop (request -> rewrite to front controller ->
2525
# redirect -> request -> ...).
2626
# So in case you get a "too many redirects" error or you always get redirected
27-
# to the startpage because your Apache does not expose the REDIRECT_STATUS
27+
# to the start page because your Apache does not expose the REDIRECT_STATUS
2828
# environment variable, you have 2 choices:
2929
# - disable this feature by commenting the following 2 lines or
3030
# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
@@ -44,7 +44,7 @@ DirectoryIndex app.php
4444
<IfModule !mod_rewrite.c>
4545
<IfModule mod_alias.c>
4646
# When mod_rewrite is not available, we instruct a temporary redirect of
47-
# the startpage to the front controller explicitly so that the website
47+
# the start page to the front controller explicitly so that the website
4848
# and the generated links can still be used.
4949
RedirectMatch 302 ^/$ /app.php/
5050
# RedirectTemp cannot be used instead

web/app.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
$kernel = new AppKernel('prod', false);
2121
//$kernel->loadClassCache();
2222
//$kernel = new AppCache($kernel);
23+
24+
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
25+
//Request::enableHttpMethodParameterOverride();
2326
$request = Request::createFromGlobals();
2427
$response = $kernel->handle($request);
2528
$response->send();

0 commit comments

Comments
 (0)