浏览代码

Merge pull request #494 from Vrtak-CZ/softDeleteable

SoftDeleteable: enable / disable for inheritance
Gediminas Morkevicius 12 年之前
父节点
当前提交
594b7e031d
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      lib/Gedmo/SoftDeleteable/Filter/SoftDeleteableFilter.php

+ 7 - 4
lib/Gedmo/SoftDeleteable/Filter/SoftDeleteableFilter.php

@@ -27,8 +27,13 @@ class SoftDeleteableFilter extends SQLFilter
 
     public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
     {
-        if (array_key_exists($targetEntity->getName(), $this->disabled)) {
+        $class = $targetEntity->getName();
+        if (array_key_exists($class, $this->disabled) && $this->disabled[$class] === true) {
             return '';
+        } elseif (array_key_exists($targetEntity->rootEntityName, $this->disabled) && $this->disabled[$targetEntity->rootEntityName] === true) {
+            if (!array_key_exists($class, $this->disabled) || $this->disabled[$class] !== false) {
+                return '';
+            }
         }
 
         $config = $this->getListener()->getConfiguration($this->getEntityManager(), $targetEntity->name);
@@ -49,9 +54,7 @@ class SoftDeleteableFilter extends SQLFilter
 
     public function enableForEntity($class)
     {
-        if (array_key_exists($class, $this->disabled)) {
-            unset($this->disabled[$class]);
-        }
+        $this->disabled[$class] = false;
     }
 
     protected function getListener()