Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-421

Add getFieldValue on ClassMetadata class

    Details

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

      Description

      I would like the attached patch to be applied since it allows you to use the ClassMetadata in a much more obvious and consistent way.

      i.e. it allows you to do :

      $this->_class->setFieldValue($entity, $field, 35);
      $this->_class->getFieldValue($entity, $field);

      instead of the current:

      $this->_class->setFieldValue($entity, $field, 35);
      $this->_class->getReflectionProperty($field)->getValue($entity);

      I am using the new style already in the NestedSet extension so it would be good if you could apply it fairly quickly if you agree.

        Activity

        Hide
        Benjamin Eberlei added a comment -

        please use $class->reflFields[$field]->getValue()

        Show
        Benjamin Eberlei added a comment - please use $class->reflFields [$field] ->getValue()
        Hide
        Roman S. Borschel added a comment -

        I think its OK to add this method, otherwise we would need to remove setFieldValue also for consistency. As an explanation for Jordi why Benjamin mentioned using reflFields is that we use this public property inside Doctrine for performance reasons (access + serialization) but for user code its probably mostly OK to use the more explicit variants.

        This method will be incuded in my next commit where I remove a lot of unnecessary other boilerplate.

        Show
        Roman S. Borschel added a comment - I think its OK to add this method, otherwise we would need to remove setFieldValue also for consistency. As an explanation for Jordi why Benjamin mentioned using reflFields is that we use this public property inside Doctrine for performance reasons (access + serialization) but for user code its probably mostly OK to use the more explicit variants. This method will be incuded in my next commit where I remove a lot of unnecessary other boilerplate.
        Hide
        Jordi Boggiano added a comment -

        Good, thank you, I was getting ready for war when I read Benjamin's response, but I'm glad someone got what I meant I'll keep using my hacked version until it's applied then.

        Show
        Jordi Boggiano added a comment - Good, thank you, I was getting ready for war when I read Benjamin's response, but I'm glad someone got what I meant I'll keep using my hacked version until it's applied then.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Jordi Boggiano
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: