Completed
Push — master ( cb2bed...021a0b )
by Alexey
04:57
created
system/modules/Exchange1c/objects/Parser/Item/Images.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -13,41 +13,41 @@  discard block
 block discarded – undo
13 13
 
14 14
 class Images extends \Migrations\Parser {
15 15
 
16
-  public function parse() {
16
+    public function parse() {
17 17
     if (is_null($this->data)) {
18
-      return;
18
+        return;
19 19
     }
20 20
     $value = $this->data;
21 21
     if (!is_array($value)) {
22
-      $value = [$value];
22
+        $value = [$value];
23 23
     }
24 24
     $ids = [];
25 25
     $dir = pathinfo($this->object->walker->migtarionLog->source, PATHINFO_DIRNAME);
26 26
     $this->model->image_file_id = 0;
27 27
     foreach ($value as $key => $imagePath) {
28
-      if (!$imagePath || !file_exists($dir . '/' . $imagePath)) {
28
+        if (!$imagePath || !file_exists($dir . '/' . $imagePath)) {
29 29
         continue;
30
-      }
31
-      $notEq = true;
32
-      $md5Cur = md5_file($dir . '/' . $imagePath);
33
-      var_dump($this->model->images);
34
-      foreach ($this->model->images as $imageId => $image) {
30
+        }
31
+        $notEq = true;
32
+        $md5Cur = md5_file($dir . '/' . $imagePath);
33
+        var_dump($this->model->images);
34
+        foreach ($this->model->images as $imageId => $image) {
35 35
         $file = $image->file;
36 36
         $md5File = '';
37 37
         if ($file->md5) {
38
-          $md5File = $file->md5;
38
+            $md5File = $file->md5;
39 39
         } elseif (file_exists($file->getRealPath())) {
40
-          $md5File = $file->md5 = md5_file($file->getRealPath());
41
-          $file->save();
40
+            $md5File = $file->md5 = md5_file($file->getRealPath());
41
+            $file->save();
42 42
         }
43 43
 
44 44
         if ($file && file_exists($file->getRealPath()) && $md5Cur == $md5File) {
45
-          $notEq = false;
46
-          $ids[] = $imageId;
47
-          break;
45
+            $notEq = false;
46
+            $ids[] = $imageId;
47
+            break;
48
+        }
48 49
         }
49
-      }
50
-      if ($notEq) {
50
+        if ($notEq) {
51 51
         $file_id = \App::$primary->files->uploadFromUrl($dir . '/' . $imagePath, ['accept_group' => 'image', 'upload_code' => 'MigrationUpload']);
52 52
         $image = new \Ecommerce\Item\Image([
53 53
             'item_id' => $this->model->pk(),
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
         ]);
56 56
         $image->save();
57 57
         $ids[] = $image->id;
58
-      } else {
58
+        } else {
59 59
         $image->weight = $key;
60
-      }
61
-      if ($image && !$this->model->image_file_id) {
60
+        }
61
+        if ($image && !$this->model->image_file_id) {
62 62
         $this->model->image_file_id = $image->file_id;
63
-      }
63
+        }
64 64
     }
65 65
     foreach ($this->model->images as $imageId => $image) {
66
-      if (!in_array($imageId, $ids)) {
66
+        if (!in_array($imageId, $ids)) {
67 67
         $image->delete();
68
-      }
68
+        }
69
+    }
69 70
     }
70
-  }
71 71
 
72 72
 }
Please login to merge, or discard this patch.
system/modules/Exchange1c/objects/Parser/Item/Options.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -13,73 +13,73 @@
 block discarded – undo
13 13
 
14 14
 class Options extends \Migrations\Parser {
15 15
 
16
-  static $options;
16
+    static $options;
17 17
 
18
-  public function parse() {
18
+    public function parse() {
19 19
     if (!Options::$options) {
20
-      Options::$options = \Ecommerce\Item\Option::getList();
20
+        Options::$options = \Ecommerce\Item\Option::getList();
21 21
     }
22 22
     $options = [];
23 23
     $modelName = 'Ecommerce\Item\Option';
24 24
     foreach ($this->data['ЗначенияСвойства'] as $opt) {
25
-      $optionId = \App::$cur->migrations->ids['parseIds']['Ecommerce\Item\Option'][$opt['Ид']]->object_id;
26
-      if ($optionId && !isset(Options::$options[$optionId])) {
25
+        $optionId = \App::$cur->migrations->ids['parseIds']['Ecommerce\Item\Option'][$opt['Ид']]->object_id;
26
+        if ($optionId && !isset(Options::$options[$optionId])) {
27 27
         Options::$options = \Ecommerce\Item\Option::getList();
28
-      }
29
-      if (isset(Options::$options[$optionId]) && Options::$options[$optionId]->type == 'select') {
28
+        }
29
+        if (isset(Options::$options[$optionId]) && Options::$options[$optionId]->type == 'select') {
30 30
         if (empty($options[$optionId])) {
31
-          $options[$optionId] = [];
31
+            $options[$optionId] = [];
32 32
         } else {
33
-          if (!Options::$options[$optionId]->advance) {
33
+            if (!Options::$options[$optionId]->advance) {
34 34
             Options::$options[$optionId]->advance = ['multi' => true];
35 35
             Options::$options[$optionId]->save();
36
-          }
36
+            }
37 37
         }
38 38
         $options[$optionId][] = \App::$cur->migrations->ids['parseIds']['Ecommerce\Item\Option\Item'][$opt['Значение']]->object_id;
39
-      } else {
39
+        } else {
40 40
         $options[$optionId] = $opt['Значение'];
41
-      }
41
+        }
42 42
     }
43 43
     $itemParams = \Ecommerce\Item\Param::getList(['where' => ['item_id', $this->model->id]]);
44 44
     foreach ($itemParams as $itemParam) {
45
-      if ($itemParam->item_option_id && !isset(Options::$options[$itemParam->item_option_id])) {
45
+        if ($itemParam->item_option_id && !isset(Options::$options[$itemParam->item_option_id])) {
46 46
         Options::$options = \Ecommerce\Item\Option::getList();
47
-      }
48
-      if (isset(Options::$options[$itemParam->item_option_id]) && Options::$options[$itemParam->item_option_id]->type == 'select') {
47
+        }
48
+        if (isset(Options::$options[$itemParam->item_option_id]) && Options::$options[$itemParam->item_option_id]->type == 'select') {
49 49
         if (empty($options[$itemParam->item_option_id]) || !in_array($itemParam->value, $options[$itemParam->item_option_id])) {
50
-          $itemParam->delete();
50
+            $itemParam->delete();
51 51
         } else {
52
-          unset($options[$itemParam->item_option_id][array_search($itemParam->value, $options[$itemParam->item_option_id])]);
52
+            unset($options[$itemParam->item_option_id][array_search($itemParam->value, $options[$itemParam->item_option_id])]);
53 53
         }
54
-      } else {
54
+        } else {
55 55
         if (empty($options[$itemParam->item_option_id])) {
56
-          $itemParam->delete();
56
+            $itemParam->delete();
57 57
         } else {
58
-          $itemParam->value = $options[$itemParam->item_option_id];
59
-          $itemParam->save();
60
-          unset($options[$itemParam->item_option_id]);
58
+            $itemParam->value = $options[$itemParam->item_option_id];
59
+            $itemParam->save();
60
+            unset($options[$itemParam->item_option_id]);
61
+        }
61 62
         }
62
-      }
63 63
     }
64 64
     foreach ($options as $optionId => $values) {
65
-      if (is_array($values)) {
65
+        if (is_array($values)) {
66 66
         foreach ($values as $value) {
67
-          $itemParam = new \Ecommerce\Item\Param([
68
-              'item_option_id' => $optionId,
69
-              'item_id' => $this->model->id,
70
-              'value' => $value
71
-          ]);
72
-          $itemParam->save();
67
+            $itemParam = new \Ecommerce\Item\Param([
68
+                'item_option_id' => $optionId,
69
+                'item_id' => $this->model->id,
70
+                'value' => $value
71
+            ]);
72
+            $itemParam->save();
73 73
         }
74
-      } else {
74
+        } else {
75 75
         $itemParam = new \Ecommerce\Item\Param([
76 76
             'item_option_id' => $optionId,
77 77
             'item_id' => $this->model->id,
78 78
             'value' => $values
79 79
         ]);
80 80
         $itemParam->save();
81
-      }
81
+        }
82
+    }
82 83
     }
83
-  }
84 84
 
85 85
 }
Please login to merge, or discard this patch.