Forráskód Böngészése

inject manager type in Admin class

Roel Sint 13 éve
szülő
commit
4d9f421490

+ 23 - 0
Admin/Admin.php

@@ -261,6 +261,13 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
      */
     protected $modelManager;
 
+    /**
+     * The manager type to use for the admin
+     *
+     * @var string
+     */
+    private $managerType;
+
     /**
      * The current request object
      *
@@ -2075,6 +2082,22 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
         $this->modelManager = $modelManager;
     }
 
+    /**
+     * @return string the manager type of the admin
+     */
+    public function getManagerType()
+    {
+        return $this->managerType;
+    }
+
+    /**
+     * @param string $type
+     */
+    public function setManagerType($type)
+    {
+        $this->managerType = $type;
+    }
+
     /**
      * Returns a unique identifier for this domain object.
      *

+ 6 - 0
Admin/AdminInterface.php

@@ -113,6 +113,12 @@ interface AdminInterface
      */
     function getModelManager();
 
+    /**
+     * @abstract
+     * @return string the manager type of the admin
+     */
+    function getManagerType();
+
     /**
      * @abstract
      * @return \Sonata\AdminBundle\Datagrid\ProxyQueryInterface

+ 2 - 0
DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php

@@ -179,6 +179,8 @@ class AddDependencyCallsCompilerPass implements CompilerPassInterface
             'label_translator_strategy' => 'sonata.admin.label.strategy.native'
         );
 
+        $definition->addMethodCall('setManagerType', array($manager_type));
+
         foreach ($defaultAddServices as $attr => $addServiceId) {
             $method = 'set'.$this->camelize($attr);