|
@@ -12,6 +12,7 @@ use Doctrine\ORM\Mapping\ClassMetaData,
|
|
*
|
|
*
|
|
* @author Gustavo Falco <comfortablynumb84@gmail.com>
|
|
* @author Gustavo Falco <comfortablynumb84@gmail.com>
|
|
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
|
|
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
|
|
|
|
+ * @author Patrik Votoček <patrik@votocek.cz>
|
|
* @package Gedmo.SoftDeleteable
|
|
* @package Gedmo.SoftDeleteable
|
|
* @subpackage Filter
|
|
* @subpackage Filter
|
|
* @link http://www.gediminasm.org
|
|
* @link http://www.gediminasm.org
|
|
@@ -22,9 +23,14 @@ class SoftDeleteableFilter extends SQLFilter
|
|
{
|
|
{
|
|
protected $listener;
|
|
protected $listener;
|
|
protected $entityManager;
|
|
protected $entityManager;
|
|
|
|
+ protected $disabled = array();
|
|
|
|
|
|
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
|
|
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
|
|
{
|
|
{
|
|
|
|
+ if (array_key_exists($targetEntity->getName(), $this->disabled)) {
|
|
|
|
+ return '';
|
|
|
|
+ }
|
|
|
|
+
|
|
$config = $this->getListener()->getConfiguration($this->getEntityManager(), $targetEntity->name);
|
|
$config = $this->getListener()->getConfiguration($this->getEntityManager(), $targetEntity->name);
|
|
|
|
|
|
if (!isset($config['softDeleteable']) || !$config['softDeleteable']) {
|
|
if (!isset($config['softDeleteable']) || !$config['softDeleteable']) {
|
|
@@ -36,6 +42,18 @@ class SoftDeleteableFilter extends SQLFilter
|
|
return $targetTableAlias.'.'.$column.' IS NULL';
|
|
return $targetTableAlias.'.'.$column.' IS NULL';
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function disableForEntity($class)
|
|
|
|
+ {
|
|
|
|
+ $this->disabled[$class] = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function enableForEntity($class)
|
|
|
|
+ {
|
|
|
|
+ if (array_key_exists($class, $this->disabled)) {
|
|
|
|
+ unset($this->disabled[$class]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
protected function getListener()
|
|
protected function getListener()
|
|
{
|
|
{
|
|
if ($this->listener === null) {
|
|
if ($this->listener === null) {
|