浏览代码

inject manager type in Admin class

Roel Sint 13 年之前
父节点
当前提交
4d9f421490
共有 3 个文件被更改,包括 31 次插入0 次删除
  1. 23 0
      Admin/Admin.php
  2. 6 0
      Admin/AdminInterface.php
  3. 2 0
      DependencyInjection/Compiler/AddDependencyCallsCompilerPass.php

+ 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);