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::
...
}
.. 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::
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::
composer require --dev symfony/browser-kit symfony/css-selector
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()
{
// app.php must return an Application instance
return require __DIR__.'/path/to/app.php';
}
......
......@@ -182,7 +182,7 @@ Other methods
~~~~~~~~~~~~~
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) {
// ...
......@@ -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));
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
following handlers are ignored.
it with a higher priority then response error handlers, because once a response
is returned, the following handlers are ignored.
.. note::
......@@ -551,6 +551,8 @@ early::
return new Response(...);
});
You can convert errors to ``Exceptions``, check out the cookbook :doc:`chapter <cookbook/error_handler>` for details.
View Handlers
-------------
......@@ -764,7 +766,7 @@ Cross-Site-Scripting attacks.
});
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
use the Silex ``json`` function::
......
......@@ -46,7 +46,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn
const VERSION = '2.0.0-DEV';
const EARLY_EVENT = 512;
const LATE_EVENT = -512;
const LATE_EVENT = -512;
protected $providers = array();
protected $booted = false;
......
......@@ -89,7 +89,7 @@ class MiddlewareListener implements EventSubscriberInterface
{
return array(
// 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),
);
}
......
......@@ -28,10 +28,10 @@ class DoctrineServiceProvider implements ServiceProviderInterface
public function register(Container $app)
{
$app['db.default_options'] = array(
'driver' => 'pdo_mysql',
'dbname' => null,
'host' => 'localhost',
'user' => 'root',
'driver' => 'pdo_mysql',
'dbname' => null,
'host' => 'localhost',
'user' => 'root',
'password' => null,
);
......
......@@ -65,13 +65,13 @@ class RememberMeServiceProvider implements ServiceProviderInterface, EventListen
$app['security.remember_me.service._proto'] = $app->protect(function ($providerKey, $options) use ($app) {
return function () use ($providerKey, $options, $app) {
$options = array_replace(array(
'name' => 'REMEMBERME',
'lifetime' => 31536000,
'path' => '/',
'domain' => null,
'secure' => false,
'httponly' => true,
'always_remember_me' => false,
'name' => 'REMEMBERME',
'lifetime' => 31536000,
'path' => '/',
'domain' => null,
'secure' => false,
'httponly' => true,
'always_remember_me' => false,
'remember_me_parameter' => '_remember_me',
), $options);
......
......@@ -38,8 +38,8 @@ class TwigServiceProvider implements ServiceProviderInterface
$app['twig'] = function ($app) {
$app['twig.options'] = array_replace(
array(
'charset' => isset($app['charset']) ? $app['charset'] : 'UTF-8',
'debug' => isset($app['debug']) ? $app['debug'] : false,
'charset' => isset($app['charset']) ? $app['charset'] : 'UTF-8',
'debug' => isset($app['debug']) ? $app['debug'] : false,
'strict_variables' => isset($app['debug']) ? $app['debug'] : false,
), $app['twig.options']
);
......
......@@ -47,9 +47,9 @@ class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface
*/
public function __construct(Container $container, array $serviceNames = array())
{
$this->container = $container;
$this->container = $container;
$this->serviceNames = $serviceNames;
$this->validators = array();
$this->validators = array();
}
/**
......
......@@ -84,5 +84,4 @@ class ViewListenerWrapper
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