浏览代码

improved cleanflaglist script

bach 1 年之前
父节点
当前提交
1beb2b4dfa
共有 1 个文件被更改,包括 25 次插入8 次删除
  1. 25 8
      cleanflaglist.script

+ 25 - 8
cleanflaglist.script

@@ -7,14 +7,31 @@
 use Drush\Drush;
 
 $this->output()->writeln("Flagging collection cleaning");
+$this->output()->writeln("options : [delete-all | delete-nullname | delete-missing | delete-dups]");
 
 // $this->output()->writeln("Hello world!");
 $this->output()->writeln("The extra options/arguments to this command were:");
 $this->output()->writeln(print_r($extra, true));
-if ($extra[0] === "delete") {
-  $delete = true;
-} else {
-  $delete = false;
+
+$delete_all = fasle;
+$delete_nullname = false;
+$delete_missing = false;
+$delete_dups = false;
+
+if ($extra[0] === "delete-all") {
+  $delete_all = true;
+}
+
+if ($extra[0] === "delete-missing") {
+  $delete_missing = true;
+}
+
+if ($extra[0] === "delete-nullname") {
+  $delete_nullname = true;
+}
+
+if ($extra[0] === "delete-dups") {
+  $delete_dups = true;
 }
 
 
@@ -43,7 +60,7 @@ foreach ($fcfd_result as $fc) {
   $this->output()->writeln($flifd_query->countQuery()->execute()->fetchField() . " items for fc " . $fc->id . ' with baseflag ' . $fc->relatedflag);
   // $this->output()->writeln(print_r($flifd_result->fetchAssoc(), true) . " items");
 
-  delete_flagingcollection($fc, $database, $delete);
+  delete_flagingcollection($fc, $database, $delete_all ? true : $delete_nullname);
 }
 
 
@@ -64,9 +81,9 @@ foreach ($fcfd_result as $fc) {
   $conf_result = $flag_query->execute();
   $count = $flag_query->countQuery()->execute()->fetchField();
   if(!$count){
-    $this->output()->writeln($fc->id . ' flagging_collection has ' . $count . " relatedflag");
+    $this->output()->writeln(' flagging_collection' . $fc->id . ' has ' . $count . " relatedflag");
     $fc_missing_relatedflag ++;
-    delete_flagingcollection($fc, $database, $delete);
+    delete_flagingcollection($fc, $database, $delete_all ? true : $delete_missing);
   }
 }
 $this->output()->writeln($fc_missing_relatedflag .' flagging_collection with missing related_flag');
@@ -96,7 +113,7 @@ foreach ($dup_result as $dup){
   $this->output()->writeln($dup->relatedflag . ' relatedflag has ' . $count . ' flagging collection');
   
   foreach ($fcfd_result as $fc) {
-    delete_flagingcollection($fc, $database, $delete);
+    delete_flagingcollection($fc, $database, $delete_all ? true : $delete_dups);
   }
 
 }