Ver código fonte

Change the method name : configure is now part of the user land to match other configure* method

Thomas Rabaix 13 anos atrás
pai
commit
f52b37b4c7

+ 14 - 1
Admin/Admin.php

@@ -461,7 +461,10 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
         $this->baseControllerName   = $baseControllerName;
     }
 
-    public function configure()
+    /**
+     * define custom variable
+     */
+    public function initialize()
     {
         $this->uniqid = uniqid();
 
@@ -470,6 +473,16 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
         }
 
         $this->baseCodeRoute = $this->getCode();
+
+        $this->configure();
+    }
+
+    /**
+     *  Allows the user to define custom variables
+     */
+    public function configure()
+    {
+
     }
 
     public function update($object)

+ 1 - 1
DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php

@@ -197,7 +197,7 @@ class AddDependencyCallsCompilerPass implements CompilerPassInterface
 
         $definition->addMethodCall('setLabel', array($label));
 
-        $definition->addMethodCall('configure');
+        $definition->addMethodCall('initialize');
 
         if (!$definition->hasMethodCall('setTemplates')) {
             $definition->addMethodCall('setTemplates', array('%sonata.admin.configuration.templates%'));

+ 5 - 5
Tests/Admin/AdminTest.php

@@ -112,7 +112,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase
         $admin = new PostAdmin('sonata.post.admin.post', 'Application\Sonata\NewsBundle\Entity\Post', 'SonataNewsBundle:PostAdmin');
         $this->assertTrue($admin->getUniqid() == "");
 
-        $admin->configure();
+        $admin->initialize();
         $this->assertFalse($admin->getUniqid() == "");
         $this->assertEquals('post', $admin->getClassnameLabel());
 
@@ -120,7 +120,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase
         $admin = new CommentAdmin('sonata.post.admin.comment', 'Application\Sonata\NewsBundle\Entity\Comment', 'SonataNewsBundle:CommentAdmin');
         $admin->setClassnameLabel('postcomment');
 
-        $admin->configure();
+        $admin->initialize();
         $this->assertEquals('postcomment', $admin->getClassnameLabel());
     }
 
@@ -129,7 +129,7 @@ class AdminTest extends \PHPUnit_Framework_TestCase
         $admin = new PostAdmin('sonata.post.admin.post', 'Application\Sonata\NewsBundle\Entity\Post', 'SonataNewsBundle:PostAdmin');
         $admin->setParentAssociationMapping('Category');
 
-        $admin->configure();
+        $admin->initialize();
         $this->assertEquals('Category', $admin->getParentAssociationMapping());
     }
 
@@ -169,10 +169,10 @@ class AdminTest extends \PHPUnit_Framework_TestCase
         $pathInfo = new \Sonata\AdminBundle\Route\PathInfoBuilder();
         $postAdmin = new PostAdmin('sonata.post.admin.post', 'Application\Sonata\NewsBundle\Entity\Post', 'SonataNewsBundle:PostAdmin');
         $postAdmin->setRouteBuilder($pathInfo);
-        $postAdmin->configure();
+        $postAdmin->initialize();
         $commentAdmin = new CommentAdmin('sonata.post.admin.comment', 'Application\Sonata\NewsBundle\Entity\Comment', 'SonataNewsBundle:CommentAdmin');
         $commentAdmin->setRouteBuilder($pathInfo);
-        $commentAdmin->configure();
+        $commentAdmin->initialize();
 
         $postAdmin->addChild($commentAdmin);