Browse Source

replace get_class per ClassUtils::getClass for entity object

Thomas Rabaix 11 years ago
parent
commit
5dfde8a4f3
3 changed files with 8 additions and 6 deletions
  1. 2 2
      Admin/Admin.php
  2. 2 1
      Admin/AdminHelper.php
  3. 4 3
      Form/ChoiceList/ModelChoiceList.php

+ 2 - 2
Admin/Admin.php

@@ -939,7 +939,7 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
     public function getClass()
     {
         if ($this->hasSubject()) {
-            return get_class($this->getSubject());
+            return ClassUtils::getClass($this->getSubject());
         }
 
         if (!$this->hasActiveSubClass()) {
@@ -947,7 +947,7 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
                 $subject = $this->getSubject();
 
                 if ($subject) {
-                    return get_class($subject);
+                    return ClassUtils::getClass($subject);
                 }
             }
 

+ 2 - 1
Admin/AdminHelper.php

@@ -10,6 +10,7 @@
 
 namespace Sonata\AdminBundle\Admin;
 
+use Doctrine\Common\Util\ClassUtils;
 use Symfony\Component\Form\FormBuilder;
 use Symfony\Component\Form\FormView;
 use Sonata\AdminBundle\Exception\NoValueException;
@@ -168,7 +169,7 @@ class AdminHelper
             $method = rtrim($method, 's');
 
             if (!method_exists($object, $method)) {
-                throw new \RuntimeException(sprintf('Please add a method %s in the %s class!', $method, get_class($object)));
+                throw new \RuntimeException(sprintf('Please add a method %s in the %s class!', $method, ClassUtils::getClass($object)));
             }
         }
 

+ 4 - 3
Form/ChoiceList/ModelChoiceList.php

@@ -11,6 +11,7 @@
 
 namespace Sonata\AdminBundle\Form\ChoiceList;
 
+use Doctrine\Common\Util\ClassUtils;
 use Symfony\Component\PropertyAccess\PropertyAccess;
 use Symfony\Component\PropertyAccess\PropertyPath;
 use Symfony\Component\Form\Exception\InvalidArgumentException;
@@ -104,8 +105,8 @@ class ModelChoiceList extends SimpleChoiceList
      *
      * If the entities were passed in the "choices" option, this method
      * does not have any significant overhead. Otherwise, if a query builder
-     * was passed in the "query" option, this builder is now used to construct 
-     * a query which is executed. In the last case, all entities for the 
+     * was passed in the "query" option, this builder is now used to construct
+     * a query which is executed. In the last case, all entities for the
      * underlying class are fetched from the repository.
      *
      * If the option "property" was passed, the property path in that option
@@ -243,7 +244,7 @@ class ModelChoiceList extends SimpleChoiceList
         try {
             return $this->modelManager->getIdentifierValues($entity);
         } catch (\Exception $e) {
-            throw new InvalidArgumentException(sprintf("Unable to retrieve the identifier values for entity %s", get_class($entity)), 0, $e);
+            throw new InvalidArgumentException(sprintf("Unable to retrieve the identifier values for entity %s", ClassUtils::getClass($entity)), 0, $e);
         }
     }