Test Setup Failed
Push — a-simpler-manager ( 38f5e5...2ffb82 )
by Ben
07:09
created
src/Site/Urls/Application/SaveUrlSlugs.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     private function saveRecord(ProvidesUrl $model, string $locale, ?string $slug, Collection $existingRecords, bool $strict = true)
44 44
     {
45 45
         // Existing ones for this locale?
46
-        $nonRedirectsWithSameLocale = $existingRecords->filter(function ($record) use ($locale) {
46
+        $nonRedirectsWithSameLocale = $existingRecords->filter(function($record) use ($locale) {
47 47
             return (
48 48
                 $record->locale == $locale &&
49 49
                 !$record->isRedirect()
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
         // If slug entry is left empty, all existing records will be deleted
54 54
         if (!$slug) {
55
-            $nonRedirectsWithSameLocale->each(function ($existingRecord) {
55
+            $nonRedirectsWithSameLocale->each(function($existingRecord) {
56 56
                 $existingRecord->delete();
57 57
             });
58 58
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         }
70 70
 
71 71
         // Only replace the existing records that differ from the current passed slugs
72
-        $nonRedirectsWithSameLocale->each(function ($existingRecord) use ($slug) {
72
+        $nonRedirectsWithSameLocale->each(function($existingRecord) use ($slug) {
73 73
             if ($existingRecord->slug != $slug) {
74 74
                 $existingRecord->replaceAndRedirect(['slug' => $slug]);
75 75
             }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         $this->deleteIdenticalRedirects($sameExistingRecords, $locale, $slug);
99 99
 
100 100
         // Also delete any urls that match this locale and slug but are related to another model
101
-        if(!$this->strict) {
101
+        if (!$this->strict) {
102 102
             $this->deleteIdenticalRecords($model, $sameExistingRecords);
103 103
         }
104 104
     }
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
      */
113 113
     private function deleteIdenticalRedirects($existingRecords, $locale, $slug): void
114 114
     {
115
-        $existingRecords->filter(function ($record) use ($locale) {
115
+        $existingRecords->filter(function($record) use ($locale) {
116 116
             return (
117 117
                 $record->locale == $locale &&
118 118
                 $record->isRedirect()
119 119
             );
120
-        })->each(function ($existingRecord) use ($slug) {
120
+        })->each(function($existingRecord) use ($slug) {
121 121
             if ($existingRecord->slug == $slug) {
122 122
                 $existingRecord->delete();
123 123
             }
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
     {
129 129
         // The old homepage url should be removed since this is no longer in effect.
130 130
         // In case of any redirect to this old homepage, the last used redirect is now back in effect.
131
-        $existingRecords->reject(function ($existingRecord) use($model) {
131
+        $existingRecords->reject(function($existingRecord) use($model) {
132 132
             return (
133 133
                 $existingRecord->model_type == $model->getMorphClass() &&
134 134
                 $existingRecord->model_id == $model->id);
135
-        })->each(function ($existingRecord) {
135
+        })->each(function($existingRecord) {
136 136
 
137 137
             // TODO: if there is a redirect to this page, we'll take this one as the new url
138 138
             $existingRecord->delete();
Please login to merge, or discard this patch.