Skip to content
Commits on Jul 26, 2012
  1. Merge sensio/master

    committed Jul 26, 2012
  2. @fabpot

    merged branch beberlei/NamedParamConverters (PR #142)

    Commits
    -------
    
    6efdeb0 0 == "false" is true, so we rather check for ===
    a719ab4 Fix bug introduced with CompilerPass refactoring
    85d7c3f Allow to disable priority registration with priority="false" attribute. Documentation of registration via DIC
    349ad35 Refactor AddParamConverterPass loop over tags.
    de202e4 Fix a bug and a comment position
    55753d1 Add documentation on named converters
    2ed098d [ParamConverter] Add support for named param converters. They preceed the iteration and make conversion much faster. Add existing converters as "doctrine.orm" and "datetime".
    
    Discussion
    ----------
    
    [ParamConverter] Add support for named param converters.
    
    Named parameter converters will allow specific choice which param converter is chosen.
    
    * avoid the iterations over many converters
    * pick specific converters that otherwise need to be invoked at very late priorities for security reasons.
    * It also makes the conversion more explicit, which could take away developer fears not understanding whats happening.
    * Cases with different inputs (Query, Request, Raw-Data) might make explicit converter choice necessary.
    
    Fixes GH-116
    
    One open question with this patch is that now every converter automatically has a priority and not a name. You cannot give a converter no priority and only make it available via name. I am thinking to change this to allow registration with priority, name and with both.
    
    * A BC solution would need to introduce <tag name="request.param_converter" priority="false" /> which needs special handling in the CompilerPAss.
    * A non BC solution would change every converter without a priority attribute in the DIC tag without priority.
    
    What do you prefer?
    
    ---------------------------------------------------------------------------
    
    by beberlei at 2012-07-25T21:38:41Z
    
    docs are missing.
    
    ---------------------------------------------------------------------------
    
    by beberlei at 2012-07-25T21:44:33Z
    
    docs are here now
    
    ---------------------------------------------------------------------------
    
    by beberlei at 2012-07-25T21:54:20Z
    
    This PR would close GH-116
    
    ---------------------------------------------------------------------------
    
    by fabpot at 2012-07-26T06:20:45Z
    
    About the question you have about priorities and names. A converter without a priority would have to be explicitly used via the annotation and the name provided, right? No automatic conversion would ever happen with such a converter?
    
    Anyway, if it does not make the code more complex, I would prefer to have a BC solution, especially because this would be managed in the compiler pass.
    
    ---------------------------------------------------------------------------
    
    by beberlei at 2012-07-26T06:47:28Z
    
    Ok i updated it the BC way. Its not a complex solution, just one simple if condition. I added a documentation for DIC registration by tag as well now.
    
    I haven't tested this code yet, i will check in some minutes at my work project and then give a +1/-1 on this PR.
    
    ---------------------------------------------------------------------------
    
    by beberlei at 2012-07-26T09:52:50Z
    
    Ok i "functionally" tested this in my application and it works after those two last fixes. You can use named converters and or priority based and the compiler pass works. Actual functionality is tested by the unitt-tests in ParamConverterManagerTest.php and works as advertised.
    fabpot committed Jul 26, 2012
  3. @fabpot

    merged branch beberlei/DoctrineFindByAssocations (PR #143)

    Commits
    -------
    
    dd7e22b Add UPGRADE.md notice of possible BC break
    56d98f3 [ParamConverter][Doctrine] allow to find by single-valued associations.
    
    Discussion
    ----------
    
    [ParamConverter][Doctrine] allow to find by single-valued associations.
    
    Fixes GH-95
    
    I initially thought this could lead to clashes when the following
    conversions are defined:
    
        /**
         * @Route("/page/{user}/{group}")
         * @ParamConverter("user", {"id": "user"})
         * @ParamConverter("group", {"id": "group"})
         */
        public function showAction(User $user, Group $group) {}
    
        class User
        {
            /** @ManyToOne(targetEntity="Group") */
            private $group;
        }
    
    However through the renaming via `id` its a find by primary key anyways. There is a slim chance before GH-141 to find two objects through `findOneBy()` which would break because of this patch, when an association was not found before and now is included in the `$criteria`.
    
    Should I add a UPGRADE notice?
    
    ---------------------------------------------------------------------------
    
    by fabpot at 2012-07-26T08:27:09Z
    
    Can you indeed add an UPGRADE note?
    
    ---------------------------------------------------------------------------
    
    by beberlei at 2012-07-26T10:52:52Z
    
    Added the UPGRADE note.
    fabpot committed Jul 26, 2012
  4. Merge named parameters

    committed Jul 26, 2012
  5. Merge sensio/master

    committed Jul 26, 2012
  6. Allow to disable priority registration with priority="false" attribut…

    …e. Documentation of registration via DIC
    committed Jul 26, 2012
Commits on Jul 25, 2012
  1. [ParamConverter] Add support for named param converters. They preceed…

    … the iteration and make conversion much faster. Add existing converters as "doctrine.orm" and "datetime".
    committed Jul 25, 2012
  2. @fabpot

    fixed CS

    fabpot committed Jul 25, 2012
  3. @fabpot

    merged branch beberlei/DoctrineParamConverterRefactoring (PR #141)

    Commits
    -------
    
    ae620b8 Backwards compatible refactoring that increases the use-cases for DoctrineParamConverter. Support for composite primary keys and for cases where multiple entities use have the same field names
    
    Discussion
    ----------
    
    [ParamConverter] Doctrine Converter Refactoring
    
    Backwards compatible refactoring that increases the use-cases for DoctrineParamConverter.
    
    * Support for composite primary keys
    * Allow explicit mapping and excludes in cases where multiple converters clash with the same field names.
    * Fix bug where an exception is thrown even when the parameter is optional.
    * Increase the code-coverage of the converter, covering find by primary key and by fields values.
    
    This brings DoctrineConverter in line with Propel converter (https://github.com/propelorm/PropelBundle/blob/1.1/Request/ParamConverter/PropelParamConverter.php) which also has 'mapping' and 'exclude' keys.
    fabpot committed Jul 25, 2012
  4. Backwards compatible refactoring that increases the use-cases for Doc…

    …trineParamConverter. Support for composite primary keys and for cases where multiple entities use have the same field names
    committed Jul 25, 2012
  5. @fabpot

    merged branch beberlei/DateTimeConverter (PR #136)

    Commits
    -------
    
    64a0a69 Fix apply and CS
    94fd1bb Allow options to pass format, documented datetime converter
    cc0350d Test for DateTimeParamConverter
    90605cb DateTimeParamConverter
    
    Discussion
    ----------
    
    [ParamConverter] DateTime converter
    
    Allow converting route or request parameters into DateTime instances in the method signature of an action.
    
    ---------------------------------------------------------------------------
    
    by lsmith77 at 2012-07-21T07:14:15Z
    
    would it be possible to also support ``Y/m/d`` with this converter?
    
    ---------------------------------------------------------------------------
    
    by stof at 2012-07-21T11:00:11Z
    
    @lsmith77 I don't why it could not support it
    
    ---------------------------------------------------------------------------
    
    by beberlei at 2012-07-22T14:44:35Z
    
    @lsmith77 well not in route attributes, but in get/post it obviously works-
    fabpot committed Jul 25, 2012
  6. @fabpot

    merged branch jaugustin/auto-add-class-for-custom-paramconverter (PR #…

    …119)
    
    Commits
    -------
    
    64aa438 this automaticaly add class for ParamConverter without class, when a typehint is provided
    
    Discussion
    ----------
    
    this add class for ParamConverter without class
    
    Hi,
    
    This add the possibility to configure the paramConverter without class param, when the parameter has a typehint:
    
    ```php
    <?php
    use Acme\BookBundle\Model\Book;
        /**
         *  @Route("/edit-book/{id}", name="edit_book")
         *  @ParamConverter("book", options={"option1"="foo"})
         *  @Template()
         */
        public function editBookAction(Book $book)
        {
        }
    ```
    
    ---------------------------------------------------------------------------
    
    by jaugustin at 2012-05-22T22:20:11Z
    
    any new on this ?
    
    ---------------------------------------------------------------------------
    
    by willdurand at 2012-05-24T09:07:13Z
    
    ping @fabpot
    
    ---------------------------------------------------------------------------
    
    by fabpot at 2012-05-25T07:43:13Z
    
    Have you tested your fix? Because I don't see how it can work.
    
    ---------------------------------------------------------------------------
    
    by jaugustin at 2012-05-25T08:11:19Z
    
    Yes I tested it, and it work.
    if your param converter has no `class` parameter and there is a typehint on the action parameter, class param will be automaticaly set, the same way as when there is no paramconverter at all.
    
    like in the example :
    
    ```php
    <?php
    use Acme\BookBundle\Model\Book;
        /**
         *  @Route("/edit-book/{id}", name="edit_book")
         *  @ParamConverter("book", options={"option1"="foo"})
         *  @Template()
         */
        public function editBookAction(Book $book)
        {
        }
    ```
    
    ---------------------------------------------------------------------------
    
    by beberlei at 2012-07-24T16:51:50Z
    
    +1 on this one
    fabpot committed Jul 25, 2012
Commits on Jul 24, 2012
  1. @jaugustin
Commits on Jul 22, 2012
  1. Doctrine Form Converter

    committed Jul 22, 2012
  2. Merge DateTimeConverter

    committed Jul 22, 2012
  3. Removed validation from ObjectParamConverter, because its not customi…

    …zable enough. It should be done by the user inside the controller
    committed Jul 22, 2012
Commits on Jul 21, 2012
  1. Fix apply and CS

    committed Jul 21, 2012
  2. Fix apply and CS

    committed Jul 21, 2012
  3. ObjectParamConverter

    committed Jul 21, 2012
Commits on Jul 20, 2012
  1. Test for DateTimeParamConverter

    committed Jul 21, 2012
  2. DateTimeParamConverter

    committed Jul 20, 2012
Commits on Jul 12, 2012
  1. @fabpot

    merged branch Seldaek/patch-1 (PR #134)

    Commits
    -------
    
    1cc791d Add clear example with two param converters
    
    Discussion
    ----------
    
    Add clear example with two param converters
    fabpot committed Jul 12, 2012
  2. @Seldaek
Commits on Jul 1, 2012
  1. @fabpot

    udpated doc for previous merge

    fabpot committed Jul 1, 2012
Something went wrong with that request. Please try again.