瀏覽代碼

Removed deprecated PropertyPath calls

WouterJ 12 年之前
父節點
當前提交
0c810e8405
共有 4 個文件被更改,包括 16 次插入8 次删除
  1. 4 2
      Admin/Admin.php
  2. 4 2
      Controller/HelperController.php
  3. 4 2
      Form/ChoiceList/ModelChoiceList.php
  4. 4 2
      Validator/ErrorElement.php

+ 4 - 2
Admin/Admin.php

@@ -13,7 +13,8 @@ namespace Sonata\AdminBundle\Admin;
 
 use Symfony\Component\Form\Form;
 use Symfony\Component\Form\FormBuilder;
-use Symfony\Component\Form\Util\PropertyPath;
+use Symfony\Component\PropertyAccess\PropertyPath;
+use Symfony\Component\PropertyAccess\PropertyAccess;
 use Symfony\Component\Validator\ValidatorInterface;
 use Symfony\Component\Translation\TranslatorInterface;
 use Symfony\Component\HttpFoundation\Request;
@@ -809,11 +810,12 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
         if ($this->isChild() && $this->getParentAssociationMapping()) {
             $parent = $this->getParent()->getObject($this->request->get($this->getParent()->getIdParameter()));
 
+            $propertyAccessor = PropertyAccess::getPropertyAccessor();
             $propertyPath = new PropertyPath($this->getParentAssociationMapping());
 
             $object = $this->getSubject();
 
-            $propertyPath->setValue($object, $parent);
+            $propertyAccessor->setValue($object, $propertyPath, $parent);
         }
 
         $this->form = $this->getFormBuilder()->getForm();

+ 4 - 2
Controller/HelperController.php

@@ -15,7 +15,8 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpFoundation\JsonResponse;
-use Symfony\Component\Form\Util\PropertyPath;
+use Symfony\Component\PropertyAccess\PropertyAccess;
+use Symfony\Component\PropertyAccess\PropertyPath;
 use Symfony\Component\HttpFoundation\Request;
 use Sonata\AdminBundle\Admin\Pool;
 use Sonata\AdminBundle\Admin\AdminHelper;
@@ -242,8 +243,9 @@ class HelperController
         }
 
         // TODO : call the validator component ...
+        $propertyAccessor = PropertyAccess::getPropertyAccessor();
         $propertyPath = new PropertyPath($field);
-        $propertyPath->setValue($object, $value);
+        $propertyAccessor->setValue($object, $propertyPath, $value);
 
         $admin->update($object);
 

+ 4 - 2
Form/ChoiceList/ModelChoiceList.php

@@ -11,7 +11,8 @@
 
 namespace Sonata\AdminBundle\Form\ChoiceList;
 
-use Symfony\Component\Form\Util\PropertyPath;
+use Symfony\Component\PropertyAccess\PropertyAccess;
+use Symfony\Component\PropertyAccess\PropertyPath;
 use Symfony\Component\Form\Exception\FormException;
 use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
 use Sonata\AdminBundle\Model\ModelManagerInterface;
@@ -131,7 +132,8 @@ class ModelChoiceList extends SimpleChoiceList
         foreach ($entities as $key => $entity) {
             if ($this->propertyPath) {
                 // If the property option was given, use it
-                $value = $this->propertyPath->getValue($entity);
+                $propertyAccessor = PropertyAccess::getPropertyAccessor();
+                $value = $propertyAccessor->getValue($entity, $this->propertyPath);
             } else {
                 // Otherwise expect a __toString() method in the entity
                 $value = (string) $entity;

+ 4 - 2
Validator/ErrorElement.php

@@ -12,7 +12,8 @@ namespace Sonata\AdminBundle\Validator;
 
 use Symfony\Bundle\FrameworkBundle\Validator\ConstraintValidatorFactory;
 use Symfony\Component\Validator\ExecutionContext;
-use Symfony\Component\Form\Util\PropertyPath;
+use Symfony\Commponent\PropertyAccess\PropertyAccess;
+use Symfony\Commponent\PropertyAccess\PropertyPath;
 use Symfony\Component\Validator\Constraint;
 
 class ErrorElement
@@ -146,7 +147,8 @@ class ErrorElement
      */
     protected function getValue()
     {
-        return $this->getCurrentPropertyPath()->getValue($this->subject);
+        $propertyAccessor = PropertyAccess::getPropertyAccessor();
+        return $propertyAccessor->getValue($this->subject, $this->getCurrentPropertyPath());
     }
 
     /**