Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-36

EntityManager#persist should accept more objects to easily persist multiple objects.

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.0-ALPHA3
    • Fix Version/s: 2.0-ALPHA3
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      I think it would be nice if the persist function would accept more objects as an arguments by using func-get-arg see the simple example below:

      Example
      <?php
        
        $user   = new \Entities\User();
        $person = new \Entities\Person();
      
        $person->setName('Wage');
        $person->setFirstNames('Jonathan');
        $person->setTitle('mr');
      
        $user->setPerson($person);
        $user->setPassword('D0ctr1ne');
      
        $em->persist($person, $user);
        $em->flush();
      
      

        Activity

        Hide
        Roman S. Borschel added a comment -

        I really dislike func_get_args in general because it makes parameters invisible on the public API without explicit correcting documentation (and grabbing parameters out of thin air, which is what func_get_args() does, doesnt look very appealing in the code, too).

        Combined with the fact that this would really be only a very small convenience, I have to say no on this one. Sorry, but thanks for the suggestion.

        What would probably be acceptable is: EntityManager#persistAll(array $entities) but then we would need such a method for remove/merge/detach as well. Sounds like too many new methods for me that will be rather rarely used and we dont want to bloat the public API like that. And it really is a one-liner in userland code:

        foreach ($entities as $entity) $em->persist($entity); 
        Show
        Roman S. Borschel added a comment - I really dislike func_get_args in general because it makes parameters invisible on the public API without explicit correcting documentation (and grabbing parameters out of thin air, which is what func_get_args() does, doesnt look very appealing in the code, too). Combined with the fact that this would really be only a very small convenience, I have to say no on this one. Sorry, but thanks for the suggestion. What would probably be acceptable is: EntityManager#persistAll(array $entities) but then we would need such a method for remove/merge/detach as well. Sounds like too many new methods for me that will be rather rarely used and we dont want to bloat the public API like that. And it really is a one-liner in userland code: foreach ($entities as $entity) $em->persist($entity);
        Hide
        Marijn Huizendveld added a comment -

        Hi Roman,

        I agree with you in keeping the API as clean as possible, its one of the most important features is you ask me from doctrine 2, that's why I'll have to agree with you.

        Thanks for concidering.

        Show
        Marijn Huizendveld added a comment - Hi Roman, I agree with you in keeping the API as clean as possible, its one of the most important features is you ask me from doctrine 2, that's why I'll have to agree with you. Thanks for concidering.

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Marijn Huizendveld
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: