Completed
Push — master ( 9a3b57...2e73c4 )
by Vadim
04:00
created
TrashBehavior.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
      * @var callable the value that will be assigned to the attributes. This should be a valid
42 42
      * PHP callable whose return value will be assigned to the current attribute(s).
43 43
      */
44
-     public $value;
44
+        public $value;
45 45
 
46 46
     /**
47 47
      * @inheritdoc
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
      * @var mixed The value to set for removed model.
31 31
      * Default is 1.
32 32
      */
33
-    public $removedFlag=1;
33
+    public $removedFlag = 1;
34 34
     /**
35 35
      * @var mixed The value to set for restored model.
36 36
      * Default is 0.
37 37
      */
38
-    public $restoredFlag=0;
38
+    public $restoredFlag = 0;
39 39
 
40 40
     /**
41 41
      * @var callable the value that will be assigned to the attributes. This should be a valid
@@ -57,18 +57,18 @@  discard block
 block discarded – undo
57 57
         }
58 58
     }
59 59
 
60
-    public function events(){
60
+    public function events() {
61 61
         return ArrayHelper::merge([
62 62
             ActiveRecord::EVENT_BEFORE_INSERT => 'checkNewRecord',
63 63
         ], parent::events());
64 64
     }
65 65
 
66
-    public function checkNewRecord($events){
66
+    public function checkNewRecord($events) {
67 67
         /* @var $owner BaseActiveRecord */
68 68
         $owner = $this->owner;
69 69
 
70
-        if($owner->hasAttribute($this->trashAttribute))
71
-            if(empty($owner->{$this->trashAttribute})||is_null($owner->{$this->trashAttribute}))
70
+        if ($owner->hasAttribute($this->trashAttribute))
71
+            if (empty($owner->{$this->trashAttribute})||is_null($owner->{$this->trashAttribute}))
72 72
                 $owner->{$this->trashAttribute} = $this->restoredFlag;
73 73
     }
74 74
 
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
77 77
         /* @var $owner BaseActiveRecord */
78 78
         $owner = $this->owner;
79 79
 
80
-        if ($this->value === null) {
81
-            if($owner->{$this->trashAttribute}==$this->restoredFlag)
80
+        if ($this->value===null) {
81
+            if ($owner->{$this->trashAttribute}==$this->restoredFlag)
82 82
             {
83 83
                 $event->isValid = false;
84
-                $owner->{$this->trashAttribute}=$this->removedFlag;
84
+                $owner->{$this->trashAttribute} = $this->removedFlag;
85 85
                 $owner->save(false);
86 86
 
87 87
                 return $this->removedFlag;
88
-            }else{
88
+            } else {
89 89
                 return true;
90 90
             }
91 91
             return false;
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
         /* @var $owner BaseActiveRecord */
100 100
         $owner = $this->owner;
101 101
 
102
-        $owner->{$this->trashAttribute}=$this->restoredFlag;
102
+        $owner->{$this->trashAttribute} = $this->restoredFlag;
103 103
 
104 104
         $owner->save(false);
105 105
     }
106 106
 
107
-    public function getIsRemoved(){
107
+    public function getIsRemoved() {
108 108
         return $this->owner->{$this->trashAttribute}==$this->removedFlag;
109 109
     }
110 110
 
111
-    public function fullTrashAttribute($removed=false){
112
-        return [$this->trashAttribute=>($removed?$this->removedFlag:$this->restoredFlag)];
111
+    public function fullTrashAttribute($removed = false) {
112
+        return [ $this->trashAttribute=>($removed ? $this->removedFlag : $this->restoredFlag) ];
113 113
     }
114 114
 }
115 115
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,9 +67,10 @@  discard block
 block discarded – undo
67 67
         /* @var $owner BaseActiveRecord */
68 68
         $owner = $this->owner;
69 69
 
70
-        if($owner->hasAttribute($this->trashAttribute))
71
-            if(empty($owner->{$this->trashAttribute})||is_null($owner->{$this->trashAttribute}))
70
+        if($owner->hasAttribute($this->trashAttribute)) {
71
+                    if(empty($owner->{$this->trashAttribute})||is_null($owner->{$this->trashAttribute}))
72 72
                 $owner->{$this->trashAttribute} = $this->restoredFlag;
73
+        }
73 74
     }
74 75
 
75 76
     protected function getValue($event)
@@ -85,7 +86,7 @@  discard block
 block discarded – undo
85 86
                 $owner->save(false);
86 87
 
87 88
                 return $this->removedFlag;
88
-            }else{
89
+            } else{
89 90
                 return true;
90 91
             }
91 92
             return false;
Please login to merge, or discard this patch.
TrashQuery.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: vadim
5
- * Date: 02.05.15
6
- * Time: 2:40
7
- */
3
+     * Created by PhpStorm.
4
+     * User: vadim
5
+     * Date: 02.05.15
6
+     * Time: 2:40
7
+     */
8 8
 
9 9
 namespace sibds\behaviors;
10 10
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 use yii\db\ActiveQuery;
13 13
 
14 14
 class TrashQuery extends ActiveQuery {
15
-    public function behaviors(){
15
+    public function behaviors() {
16 16
         return [
17 17
             TrashQueryBehavior::className(),
18 18
         ];
Please login to merge, or discard this patch.
TrashQueryBehavior.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: vadim
5
- * Date: 01.05.15
6
- * Time: 17:49
7
- */
3
+     * Created by PhpStorm.
4
+     * User: vadim
5
+     * Date: 01.05.15
6
+     * Time: 17:49
7
+     */
8 8
 
9 9
 namespace sibds\behaviors;
10 10
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
     public function withRemoved() {
34 34
         $model = new $this->owner->modelClass();
35 35
 
36
-        return $this->owner->where([$model->trashAttribute=>[$model->removedFlag,$model->restoredFlag]]);
36
+        return $this->owner->where([ $model->trashAttribute=>[ $model->removedFlag, $model->restoredFlag ] ]);
37 37
     }
38 38
 
39 39
     public function onlyActive() {
Please login to merge, or discard this patch.