Completed
Push — master ( 5a58a5...b32b5d )
by Alexey
06:18
created
system/modules/Migrations/objects/Parser/Object/Value.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -13,85 +13,85 @@
 block discarded – undo
13 13
 
14 14
 class Value extends \Migrations\Parser {
15 15
 
16
-  public function parse() {
16
+    public function parse() {
17 17
     $options = $this->param->options ? json_decode($this->param->options, true) : [];
18 18
     $modelName = get_class($this->model);
19 19
     $cols = $modelName::$cols;
20 20
     $value = $this->data;
21 21
     if (is_array($value)) {
22
-      $value = '';
22
+        $value = '';
23 23
     }
24 24
     if (!empty($cols[$this->param->value])) {
25
-      $col = $cols[$this->param->value];
26
-      if ($col['type'] == 'dynamicType') {
25
+        $col = $cols[$this->param->value];
26
+        if ($col['type'] == 'dynamicType') {
27 27
         switch ($col['typeSource']) {
28
-          case'selfMethod':
28
+            case'selfMethod':
29 29
             $type = $this->model->{$col['selfMethod']}();
30 30
             if (is_array($type)) {
31
-              if (strpos($type['relation'], ':')) {
31
+                if (strpos($type['relation'], ':')) {
32 32
                 $relationPath = explode(':', $type['relation']);
33 33
                 $relationName = array_pop($relationPath);
34 34
                 $item = $this->model;
35 35
                 foreach ($relationPath as $path) {
36
-                  $item = $item->$path;
36
+                    $item = $item->$path;
37 37
                 }
38 38
                 $itemModel = get_class($item);
39 39
                 $relation = $itemModel::getRelation($relationName);
40 40
                 $sourceModel = $relation['model'];
41
-              } else {
41
+                } else {
42 42
                 $relation = $modelName::getRelation($type['relation']);
43 43
                 $sourceModel = $relation['model'];
44
-              }
45
-              $objectId = \App::$cur->migrations->findObject((string) $value, $sourceModel);
46
-              if ($objectId) {
44
+                }
45
+                $objectId = \App::$cur->migrations->findObject((string) $value, $sourceModel);
46
+                if ($objectId) {
47 47
                 $value = $objectId->object_id;
48
-              }
48
+                }
49 49
             }
50 50
             break;
51 51
         }
52
-      } else {
52
+        } else {
53 53
         $type = $col['type'];
54
-      }
54
+        }
55 55
     } else {
56
-      $type = 'text';
56
+        $type = 'text';
57 57
     }
58 58
 
59 59
     if (!empty($options['valueReplace'])) {
60
-      $values = $this->param->values(['key' => 'original']);
61
-      if (empty($values[$value])) {
60
+        $values = $this->param->values(['key' => 'original']);
61
+        if (empty($values[$value])) {
62 62
         $valueObject = new \Migrations\Migration\Object\Param\Value();
63 63
         $valueObject->param_id = $this->param->id;
64 64
         $valueObject->original = $value;
65 65
         $valueObject->save();
66
-      } else {
66
+        } else {
67 67
         $valueObject = $values[$value];
68
-      }
69
-      $value = $valueObject->replace;
68
+        }
69
+        $value = $valueObject->replace;
70 70
     }
71 71
     switch ($type) {
72
-      case 'image':
72
+        case 'image':
73 73
         $notEq = true;
74 74
         $dir = pathinfo($this->object->walker->migtarionLog->source, PATHINFO_DIRNAME);
75 75
         if ($this->model->{$this->param->value}) {
76
-          $file = \Files\File::get($this->model->{$this->param->value});
77
-          if ($file && $value && file_exists($dir . '/' . $value) && file_exists(\App::$primary->path . $file->path) && md5_file($dir . '/' . $value) == md5_file(\App::$primary->path . $file->path)) {
76
+            $file = \Files\File::get($this->model->{$this->param->value});
77
+            if ($file && $value && file_exists($dir . '/' . $value) && file_exists(\App::$primary->path . $file->path) && md5_file($dir . '/' . $value) == md5_file(\App::$primary->path . $file->path)) {
78 78
             $notEq = false;
79
-          }
80
-          if ($file && $notEq) {
79
+            }
80
+            if ($file && $notEq) {
81 81
             $file->delete();
82 82
             $this->model->{$this->param->value} = 0;
83
-          }
83
+            }
84 84
         }
85 85
         if ($notEq) {
86
-          $this->model->{$this->param->value} = \App::$primary->files->uploadFromUrl($dir . '/' . $value, ['accept_group' => 'image', 'upload_code' => 'MigrationUpload']);
86
+            $this->model->{$this->param->value} = \App::$primary->files->uploadFromUrl($dir . '/' . $value, ['accept_group' => 'image', 'upload_code' => 'MigrationUpload']);
87 87
         }
88 88
         break;
89
-      default:
89
+        default:
90 90
         if (is_array($value)) {
91
-          $value = implode(' ', $value);
91
+            $value = implode(' ', $value);
92 92
         }
93 93
         $this->model->{$this->param->value} = $value;
94 94
     }
95
-  }
95
+    }
96 96
 
97 97
 }
Please login to merge, or discard this patch.