1. 24 Jun, 2013 1 commit
  2. 19 Jun, 2013 2 commits
    • Fabien Potencier's avatar
      merged branch TomAdam/pr-update-middleware-doc (PR #725) · d8776876
      Fabien Potencier authored
      This PR was submitted for the master branch but it was merged into the 1.0 branch instead (closes #725).
      
      Discussion
      ----------
      
      Alter app references in middleware doc
      
      I use ControllerProvider's and functions for my controllers, and I rely on the ````Application```` and ````Request```` being injected via the parameters of each function. Today I happened to need to build some middleware, but found that ````public function before(Application $app)```` resulted in a fatal as the middleware does not use type hinting to set parameters like controllers do. On digging a bit deeper I found in ````Silex\EventListener\MiddlewareListener.php::onKernelRequest```` the following line:
      ````
      $ret = call_user_func($callback, $request, $this->app);
      ````
      This injects application as the second parameter. I'm really happy that it does do this, but the parameter order seems a little strange to me. It's a bit at odds with the rest of the documentation on controllers - the general method prototype is ````method(Application $app, Request $request)````. Given this, I would have expected the app to come first in the parameter list. The same applies to the after callback, except it has ````Response```` between ````Request```` and ````Application````.
      
      The global middleware defined in ````Application```` do not inject the app in any of the callbacks, confusing the matter further. My pattern doesn't actually require this, but some people's might. Is there a reason this hasn't been done? It would be very simple to add, given the three methods are inside the ````Application```` class itself.
      
      The ideal fix to this would be that the middleware use type hinting to apply the parameters, but this is complicated by the callbacks occurring in two classes, neither of which are local to the existing type hinting code. At the very least I think this functionality should be documented, so this is what I have provided in the PR.
      
      Commits
      -------
      
      ddc9b92 Alter app references in middleware doc
      d8776876
    • Tom Adam's avatar
      Alter app references in middleware doc · 120bfa9a
      Tom Adam authored
      120bfa9a
  3. 06 Jun, 2013 4 commits
  4. 08 May, 2013 2 commits
  5. 07 May, 2013 2 commits
  6. 04 May, 2013 2 commits
  7. 03 May, 2013 10 commits
  8. 02 May, 2013 1 commit
  9. 01 May, 2013 2 commits
  10. 30 Apr, 2013 2 commits
  11. 27 Apr, 2013 1 commit
  12. 26 Apr, 2013 4 commits
  13. 24 Apr, 2013 1 commit
    • Fabien Potencier's avatar
      merged branch alexkappa/master (PR #628) · 8bf675f5
      Fabien Potencier authored
      This PR was merged into the master branch.
      
      Discussion
      ----------
      
      Ported ConstraintValidatorFactory.php to Silex
      
      Included a modified version of `ConstraintValidatorFactory` to Silex for use with custom constraints.
      
      Since Silex comes with `ValidatorServiceProvider` built in, I guess it makes sense to include this, in case users might want dependencies with their custom validators.
      
      Usage would be:
      
      ```php
      // Custom.php
      public function validatedBy()
      {
          return 'my.validator.custom';
      }
      
      // index.php
      $app['validator.custom'] = $app->share(function ($app) {
          return new CustomValidator();
      });
      $app->register(new ValidatorServiceProvider(), array(
          'validator.validator_service_ids' => array(
              'my.validator.custom' => 'validator.custom'
          )
      ));
      ```
      
      Commits
      -------
      
      c4466a18 Changed constructor type hint to Pimple
      fd72c6ab Incorporated changes suggested by @Igorow. Separating $this->validators (instances) and $this->serviceNames.
      fa15389b Separating validator service names and instances
      0c3234d2 Minor refactoring
      83266af9 Changed mapping of 'validator.validator_service_ids' to use ternary operator
      278c5e01 Backward compatibility for UserPasswordValidator
      40734452 Changed deprecated namespaces
      4d8956f3 Added custom constraint and validator to properly test the ConstraintValidatorFactory.
      b45b4fb2 SecurityServiceProvider now registers a UserPasswordValidator if ValidatorServiceProvider is registered.
      70c1e365 Registering a ValidatorServiceProvider can take a validator.validator_service_ids parameter which is now an associative array of aliases as keys and service names as values so that ConstraintValidatorFactory can lazy load the validators.
      77af56be Removed Symfony\Component\Validator\ConstraintValidatorFactory altogether from ValidatorServiceProvider. Custom validators are now lazy loaded. removed obsolete test.
      423138aa - Type hint in Silex\ConstraintValidatorFactory constructor for container - Modifed Silex\Provider\ValidatorServiceProvider to accept an optional   'validator.validator_service_ids' parameter wich allows users to register   custom validators. - Added test to verify that if users registered ValidatorServiceProvider   using optional 'validator.validator_service_ids' parameter then the new   Silex\ConstraintValidatorFactory will be used instead of the one provided   in  Symfony.
      eaf0af2a Ported ConstraintValidatorFactory.php to Silex/Pimple
      8bf675f5
  14. 23 Apr, 2013 2 commits
  15. 22 Apr, 2013 1 commit
  16. 12 Apr, 2013 1 commit
  17. 11 Apr, 2013 2 commits