Commit 03705ed2 authored by Fabien Potencier's avatar Fabien Potencier

Merge branch '1.3'

* 1.3:
  fixed CS
  Update usage.rst
  tweaks the testing docs

Conflicts:
	src/Silex/Application.php
	src/Silex/Application/SecurityTrait.php
	src/Silex/Provider/TwigServiceProvider.php
parents 21632f0e 4422f429
...@@ -70,6 +70,11 @@ use it by making your test extend it:: ...@@ -70,6 +70,11 @@ use it by making your test extend it::
... ...
} }
.. caution::
If you need to override the ``setUp()`` method, don't forget to call the
parent (``parent::setUp()``) to call the Silex default setup.
.. note:: .. note::
If you want to use the Symfony ``WebTestCase`` class you will need to If you want to use the Symfony ``WebTestCase`` class you will need to
...@@ -80,10 +85,11 @@ use it by making your test extend it:: ...@@ -80,10 +85,11 @@ use it by making your test extend it::
composer require --dev symfony/browser-kit symfony/css-selector composer require --dev symfony/browser-kit symfony/css-selector
For your WebTestCase, you will have to implement a ``createApplication`` For your WebTestCase, you will have to implement a ``createApplication``
method, which returns your application. It will probably look like this:: method, which returns your application instance::
public function createApplication() public function createApplication()
{ {
// app.php must return an Application instance
return require __DIR__.'/path/to/app.php'; return require __DIR__.'/path/to/app.php';
} }
......
...@@ -182,7 +182,7 @@ Other methods ...@@ -182,7 +182,7 @@ Other methods
~~~~~~~~~~~~~ ~~~~~~~~~~~~~
You can create controllers for most HTTP methods. Just call one of these You can create controllers for most HTTP methods. Just call one of these
methods on your application: ``get``, ``post``, ``put``, ``delete``:: methods on your application: ``get``, ``post``, ``put``, ``delete``, ``patch``, ``options``::
$app->put('/blog/{id}', function ($id) { $app->put('/blog/{id}', function ($id) {
// ... // ...
...@@ -513,8 +513,8 @@ setting a more specific type hint for the Closure argument:: ...@@ -513,8 +513,8 @@ setting a more specific type hint for the Closure argument::
return new Response('Error', 404 /* ignored */, array('X-Status-Code' => 200)); return new Response('Error', 404 /* ignored */, array('X-Status-Code' => 200));
If you want to use a separate error handler for logging, make sure you register If you want to use a separate error handler for logging, make sure you register
it before the response error handlers, because once a response is returned, the it with a higher priority then response error handlers, because once a response
following handlers are ignored. is returned, the following handlers are ignored.
.. note:: .. note::
...@@ -551,6 +551,8 @@ early:: ...@@ -551,6 +551,8 @@ early::
return new Response(...); return new Response(...);
}); });
You can convert errors to ``Exceptions``, check out the cookbook :doc:`chapter <cookbook/error_handler>` for details.
View Handlers View Handlers
------------- -------------
...@@ -764,7 +766,7 @@ Cross-Site-Scripting attacks. ...@@ -764,7 +766,7 @@ Cross-Site-Scripting attacks.
}); });
If you use the Twig template engine, you should use its escaping or even If you use the Twig template engine, you should use its escaping or even
auto-escaping mechanisms. auto-escaping mechanisms. Check out the *Providers* :doc:`chapter <providers/twig>` for details.
* **Escaping JSON**: If you want to provide data in JSON format you should * **Escaping JSON**: If you want to provide data in JSON format you should
use the Silex ``json`` function:: use the Silex ``json`` function::
......
...@@ -46,7 +46,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn ...@@ -46,7 +46,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn
const VERSION = '2.0.0-DEV'; const VERSION = '2.0.0-DEV';
const EARLY_EVENT = 512; const EARLY_EVENT = 512;
const LATE_EVENT = -512; const LATE_EVENT = -512;
protected $providers = array(); protected $providers = array();
protected $booted = false; protected $booted = false;
......
...@@ -89,7 +89,7 @@ class MiddlewareListener implements EventSubscriberInterface ...@@ -89,7 +89,7 @@ class MiddlewareListener implements EventSubscriberInterface
{ {
return array( return array(
// this must be executed after the late events defined with before() (and their priority is -512) // this must be executed after the late events defined with before() (and their priority is -512)
KernelEvents::REQUEST => array('onKernelRequest', -1024), KernelEvents::REQUEST => array('onKernelRequest', -1024),
KernelEvents::RESPONSE => array('onKernelResponse', 128), KernelEvents::RESPONSE => array('onKernelResponse', 128),
); );
} }
......
...@@ -28,10 +28,10 @@ class DoctrineServiceProvider implements ServiceProviderInterface ...@@ -28,10 +28,10 @@ class DoctrineServiceProvider implements ServiceProviderInterface
public function register(Container $app) public function register(Container $app)
{ {
$app['db.default_options'] = array( $app['db.default_options'] = array(
'driver' => 'pdo_mysql', 'driver' => 'pdo_mysql',
'dbname' => null, 'dbname' => null,
'host' => 'localhost', 'host' => 'localhost',
'user' => 'root', 'user' => 'root',
'password' => null, 'password' => null,
); );
......
...@@ -65,13 +65,13 @@ class RememberMeServiceProvider implements ServiceProviderInterface, EventListen ...@@ -65,13 +65,13 @@ class RememberMeServiceProvider implements ServiceProviderInterface, EventListen
$app['security.remember_me.service._proto'] = $app->protect(function ($providerKey, $options) use ($app) { $app['security.remember_me.service._proto'] = $app->protect(function ($providerKey, $options) use ($app) {
return function () use ($providerKey, $options, $app) { return function () use ($providerKey, $options, $app) {
$options = array_replace(array( $options = array_replace(array(
'name' => 'REMEMBERME', 'name' => 'REMEMBERME',
'lifetime' => 31536000, 'lifetime' => 31536000,
'path' => '/', 'path' => '/',
'domain' => null, 'domain' => null,
'secure' => false, 'secure' => false,
'httponly' => true, 'httponly' => true,
'always_remember_me' => false, 'always_remember_me' => false,
'remember_me_parameter' => '_remember_me', 'remember_me_parameter' => '_remember_me',
), $options); ), $options);
......
...@@ -38,8 +38,8 @@ class TwigServiceProvider implements ServiceProviderInterface ...@@ -38,8 +38,8 @@ class TwigServiceProvider implements ServiceProviderInterface
$app['twig'] = function ($app) { $app['twig'] = function ($app) {
$app['twig.options'] = array_replace( $app['twig.options'] = array_replace(
array( array(
'charset' => isset($app['charset']) ? $app['charset'] : 'UTF-8', 'charset' => isset($app['charset']) ? $app['charset'] : 'UTF-8',
'debug' => isset($app['debug']) ? $app['debug'] : false, 'debug' => isset($app['debug']) ? $app['debug'] : false,
'strict_variables' => isset($app['debug']) ? $app['debug'] : false, 'strict_variables' => isset($app['debug']) ? $app['debug'] : false,
), $app['twig.options'] ), $app['twig.options']
); );
......
...@@ -47,9 +47,9 @@ class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface ...@@ -47,9 +47,9 @@ class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface
*/ */
public function __construct(Container $container, array $serviceNames = array()) public function __construct(Container $container, array $serviceNames = array())
{ {
$this->container = $container; $this->container = $container;
$this->serviceNames = $serviceNames; $this->serviceNames = $serviceNames;
$this->validators = array(); $this->validators = array();
} }
/** /**
......
...@@ -84,5 +84,4 @@ class ViewListenerWrapper ...@@ -84,5 +84,4 @@ class ViewListenerWrapper
return true; return true;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment