@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | // Constraints |
40 | 40 | if (!isset($values['action'])) { |
41 | - throw new \InvalidArgumentException('Set reference array is missing required values for the "action" keys. Given: ' . print_r($values, true)); |
|
41 | + throw new \InvalidArgumentException('Set reference array is missing required values for the "action" keys. Given: '.print_r($values, true)); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | return new static( |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | { |
54 | 54 | $sets = config('chief.sets', []); |
55 | 55 | |
56 | - return collect($sets)->map(function ($set, $key) { |
|
56 | + return collect($sets)->map(function($set, $key) { |
|
57 | 57 | return SetReference::fromArray($key, $set); |
58 | 58 | }); |
59 | 59 | } |
60 | 60 | |
61 | 61 | public static function find($key): ?SetReference |
62 | 62 | { |
63 | - return static::all()->filter(function ($ref) use ($key) { |
|
63 | + return static::all()->filter(function($ref) use ($key) { |
|
64 | 64 | return $ref->key() == $key; |
65 | 65 | })->first(); |
66 | 66 | } |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | private static function validateAction($class, $method) |
153 | 153 | { |
154 | 154 | if (!class_exists($class)) { |
155 | - throw new \InvalidArgumentException('The class [' . $class . '] isn\'t a valid class reference or does not exist in the chief-settings.sets config entry.'); |
|
155 | + throw new \InvalidArgumentException('The class ['.$class.'] isn\'t a valid class reference or does not exist in the chief-settings.sets config entry.'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | if (!method_exists($class, $method)) { |
159 | - throw new \InvalidArgumentException('The method [' . $method . '] does not exist on the class [' . $class . ']. Make sure you provide a valid method to the action value in the chief-settings.sets config entry.'); |
|
159 | + throw new \InvalidArgumentException('The method ['.$method.'] does not exist on the class ['.$class.']. Make sure you provide a valid method to the action value in the chief-settings.sets config entry.'); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace Thinktomorrow\Chief\Old\PageBuilder; |
6 | 6 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $availableChildren = AvailableChildren::forParent($model); |
43 | 43 | |
44 | 44 | // Only include modules of this model or shared ones. |
45 | - $modules = $availableChildren->onlyModules()->reject(function ($module) use ($model) { |
|
45 | + $modules = $availableChildren->onlyModules()->reject(function($module) use ($model) { |
|
46 | 46 | return $module->owner_id != null && $module->owner_id != $model->id; |
47 | 47 | }); |
48 | 48 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $available_sets = ModelReferencePresenter::toGroupedSelectValues($availableChildren->onlySets())->toArray(); |
52 | 52 | |
53 | 53 | // Current sections |
54 | - $sections = $model->children()->map(function ($section, $index) use($model) { |
|
54 | + $sections = $model->children()->map(function($section, $index) use($model) { |
|
55 | 55 | // if ($section instanceof TranslatableContract) { |
56 | 56 | // |
57 | 57 | // } |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | $trans = []; |
89 | 89 | |
90 | 90 | // Has dynamic attributes |
91 | - if(public_method_exists($model, 'dynamic')) { |
|
91 | + if (public_method_exists($model, 'dynamic')) { |
|
92 | 92 | foreach (config('chief.locales') as $locale) { |
93 | 93 | $trans[$locale] = []; |
94 | 94 | |
95 | - foreach($model->rawDynamicValues() as $key => $values) { |
|
96 | - if(is_array($values)) { |
|
97 | - foreach($values as $dynamicLocale => $dynamicValue) { |
|
98 | - if($dynamicLocale === $locale) { |
|
95 | + foreach ($model->rawDynamicValues() as $key => $values) { |
|
96 | + if (is_array($values)) { |
|
97 | + foreach ($values as $dynamicLocale => $dynamicValue) { |
|
98 | + if ($dynamicLocale === $locale) { |
|
99 | 99 | $trans[$locale][$key] = $dynamicValue; |
100 | 100 | } |
101 | 101 | } |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | // Astrotomic translatable |
108 | - if($model instanceof Translatable) { |
|
108 | + if ($model instanceof Translatable) { |
|
109 | 109 | foreach (config('chief.locales') as $locale) { |
110 | - if(!isset($trans[$locale])) $trans[$locale] = []; |
|
110 | + if (!isset($trans[$locale])) $trans[$locale] = []; |
|
111 | 111 | |
112 | 112 | $trans[$locale] = array_merge($trans[$locale], $model->getTranslation($locale)->toArray()); |
113 | 113 | } |
@@ -107,7 +107,9 @@ |
||
107 | 107 | // Astrotomic translatable |
108 | 108 | if($model instanceof Translatable) { |
109 | 109 | foreach (config('chief.locales') as $locale) { |
110 | - if(!isset($trans[$locale])) $trans[$locale] = []; |
|
110 | + if(!isset($trans[$locale])) { |
|
111 | + $trans[$locale] = []; |
|
112 | + } |
|
111 | 113 | |
112 | 114 | $trans[$locale] = array_merge($trans[$locale], $model->getTranslation($locale)->toArray()); |
113 | 115 | } |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | { |
29 | 29 | $types = config('chief.menus', []); |
30 | 30 | |
31 | - return collect($types)->map(function ($menu, $key) { |
|
31 | + return collect($types)->map(function($menu, $key) { |
|
32 | 32 | return new static($key, $menu['label'], $menu['view']); |
33 | 33 | }); |
34 | 34 | } |
35 | 35 | |
36 | 36 | public static function find($key): ?self |
37 | 37 | { |
38 | - return static::all()->filter(function ($menu) use ($key) { |
|
38 | + return static::all()->filter(function($menu) use ($key) { |
|
39 | 39 | return $menu->key() == $key; |
40 | 40 | })->first(); |
41 | 41 | } |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | { |
85 | 85 | $menu = []; |
86 | 86 | |
87 | - $this->items()->each(function ($item) use (&$menu) { |
|
87 | + $this->items()->each(function($item) use (&$menu) { |
|
88 | 88 | $menu[] = sprintf('<li><a href="%s">%s</a></li>', $item->url, $item->label); |
89 | 89 | }); |
90 | 90 | |
91 | - return '<ul>' . implode('', $menu) . '</ul>'; |
|
91 | + return '<ul>'.implode('', $menu).'</ul>'; |
|
92 | 92 | } |
93 | 93 | } |
@@ -20,19 +20,19 @@ |
||
20 | 20 | public function update(Request $request) |
21 | 21 | { |
22 | 22 | /** @var ProvidesUrl|Model $model */ |
23 | - $model = (new ModelReference($request->modelClass, (int) $request->modelId))->instance(); |
|
23 | + $model = (new ModelReference($request->modelClass, (int)$request->modelId))->instance(); |
|
24 | 24 | |
25 | 25 | $this->validate($request, ['links' => [ |
26 | - 'array', 'min:1', new UniqueUrlSlugRule($model, $model),], [], ['links.*' => 'taalspecifieke link'] |
|
26 | + 'array', 'min:1', new UniqueUrlSlugRule($model, $model), ], [], ['links.*' => 'taalspecifieke link'] |
|
27 | 27 | ]); |
28 | 28 | |
29 | 29 | (new SaveUrlSlugs())->handle($model, $request->input('links', [])); |
30 | 30 | |
31 | 31 | // Push update to homepage setting value |
32 | 32 | // TODO: we should just fetch the homepages and push that instead... |
33 | - UrlRecord::getByModel($model)->reject(function ($record) { |
|
33 | + UrlRecord::getByModel($model)->reject(function($record) { |
|
34 | 34 | return ($record->isRedirect() || !$record->isHomepage()); |
35 | - })->each(function ($record) { |
|
35 | + })->each(function($record) { |
|
36 | 36 | app(ChangeHomepage::class)->onUrlChanged($record); |
37 | 37 | }); |
38 | 38 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | private function saveRecord(ProvidesUrl $model, string $locale, ?string $slug, Collection $existingRecords) |
39 | 39 | { |
40 | 40 | // Existing ones for this locale? |
41 | - $nonRedirectsWithSameLocale = $existingRecords->filter(function ($record) use ($locale) { |
|
41 | + $nonRedirectsWithSameLocale = $existingRecords->filter(function($record) use ($locale) { |
|
42 | 42 | return ( |
43 | 43 | $record->locale == $locale && |
44 | 44 | !$record->isRedirect() |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | // If slug entry is left empty, all existing records will be deleted |
49 | 49 | if (!$slug) { |
50 | - $nonRedirectsWithSameLocale->each(function ($existingRecord) { |
|
50 | + $nonRedirectsWithSameLocale->each(function($existingRecord) { |
|
51 | 51 | $existingRecord->delete(); |
52 | 52 | }); |
53 | 53 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | // Only replace the existing records that differ from the current passed slugs |
67 | - $nonRedirectsWithSameLocale->each(function ($existingRecord) use ($slug) { |
|
67 | + $nonRedirectsWithSameLocale->each(function($existingRecord) use ($slug) { |
|
68 | 68 | if ($existingRecord->slug != $slug) { |
69 | 69 | $existingRecord->replaceAndRedirect(['slug' => $slug]); |
70 | 70 | } |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | */ |
106 | 106 | private function deleteIdenticalRedirects($existingRecords, $locale, $slug): void |
107 | 107 | { |
108 | - $existingRecords->filter(function ($record) use ($locale) { |
|
108 | + $existingRecords->filter(function($record) use ($locale) { |
|
109 | 109 | return ( |
110 | 110 | $record->locale == $locale && |
111 | 111 | $record->isRedirect() |
112 | 112 | ); |
113 | - })->each(function ($existingRecord) use ($slug) { |
|
113 | + })->each(function($existingRecord) use ($slug) { |
|
114 | 114 | if ($existingRecord->slug == $slug) { |
115 | 115 | $existingRecord->delete(); |
116 | 116 | } |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | |
126 | 126 | // The old homepage url should be removed since this is no longer in effect. |
127 | 127 | // In case of any redirect to this old homepage, the last used redirect is now back in effect. |
128 | - $existingRecords->reject(function ($existingRecord) { |
|
128 | + $existingRecords->reject(function($existingRecord) { |
|
129 | 129 | return ( |
130 | 130 | $existingRecord->model_type == $model->getMorphClass() && |
131 | 131 | $existingRecord->model_id == $model->id); |
132 | - })->each(function ($existingRecord) { |
|
132 | + })->each(function($existingRecord) { |
|
133 | 133 | |
134 | 134 | // TODO: if there is a redirect to this page, we'll take this one as the new url |
135 | 135 | $existingRecord->delete(); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | { |
23 | 23 | return new static($model, \Thinktomorrow\Chief\Site\Urls\UrlRecord::getByModel($model) |
24 | 24 | ->groupBy('locale') |
25 | - ->map(function ($records) { |
|
25 | + ->map(function($records) { |
|
26 | 26 | return $records->sortBy('redirect_id')->sortByDesc('created_at'); |
27 | 27 | })); |
28 | 28 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $currentRecord = $this->urlRecords->get($locale, collect())->reject->isRedirect()->first(); |
55 | 55 | |
56 | 56 | $values[$locale] = (object)[ |
57 | - 'host' => $this->model->resolveUrl($locale, $this->model->baseUrlSegment($locale)) . '/', |
|
57 | + 'host' => $this->model->resolveUrl($locale, $this->model->baseUrlSegment($locale)).'/', |
|
58 | 58 | 'fixedSegment' => $this->model->baseUrlSegment($locale), |
59 | 59 | 'value' => $currentRecord |
60 | 60 | ? $this->rawSlugValue($currentRecord->slug, $this->model->baseUrlSegment($locale)) |
@@ -67,7 +67,7 @@ |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | if (config('chief.strict')) { |
70 | - throw new NotFoundViewKey('Missing view key. Please add a [viewKey] property to ' . get_class($this)); |
|
70 | + throw new NotFoundViewKey('Missing view key. Please add a [viewKey] property to '.get_class($this)); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | return ''; |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | |
40 | 40 | // Set required paths |
41 | 41 | $this->dirs = ['base' => $this->settings['base_path'] ?? base_path()]; |
42 | - $this->dirs['model'] = $this->settings['model_path'] ?? $this->dirs['base'] . '/' . config('chief.domain.path', 'src'); |
|
43 | - $this->dirs['views'] = $this->settings['views_path'] ?? $this->dirs['base'] . '/resources/views'; |
|
44 | - $this->dirs['controller'] = $this->settings['controller_path'] ?? $this->dirs['base'] . '/app/Http/Controllers'; |
|
45 | - $this->files['routes'] = $this->settings['routes_file'] ?? $this->dirs['base'] . '/routes/web.php'; |
|
42 | + $this->dirs['model'] = $this->settings['model_path'] ?? $this->dirs['base'].'/'.config('chief.domain.path', 'src'); |
|
43 | + $this->dirs['views'] = $this->settings['views_path'] ?? $this->dirs['base'].'/resources/views'; |
|
44 | + $this->dirs['controller'] = $this->settings['controller_path'] ?? $this->dirs['base'].'/app/Http/Controllers'; |
|
45 | + $this->files['routes'] = $this->settings['routes_file'] ?? $this->dirs['base'].'/routes/web.php'; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function handle() |
@@ -64,19 +64,19 @@ discard block |
||
64 | 64 | private function publishModel() |
65 | 65 | { |
66 | 66 | $this->publishFile( |
67 | - __DIR__ . '/stubs/model.php.stub', |
|
68 | - $to = $this->dirs['model'] . '/' . ucfirst($this->plural) . '/' . ucfirst($this->singular) . '.php', |
|
67 | + __DIR__.'/stubs/model.php.stub', |
|
68 | + $to = $this->dirs['model'].'/'.ucfirst($this->plural).'/'.ucfirst($this->singular).'.php', |
|
69 | 69 | 'model' |
70 | 70 | ); |
71 | 71 | |
72 | - $this->addToConfig('collections', [$this->plural => $this->guessNamespace() . '\\' . ucfirst($this->singular)]); |
|
72 | + $this->addToConfig('collections', [$this->plural => $this->guessNamespace().'\\'.ucfirst($this->singular)]); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | private function publishController() |
76 | 76 | { |
77 | 77 | $this->publishFile( |
78 | - __DIR__ . '/stubs/controller.php.stub', |
|
79 | - $to = $this->dirs['controller'] . '/' . ucfirst($this->plural) . '/' . ucfirst($this->singular) . '.php', |
|
78 | + __DIR__.'/stubs/controller.php.stub', |
|
79 | + $to = $this->dirs['controller'].'/'.ucfirst($this->plural).'/'.ucfirst($this->singular).'.php', |
|
80 | 80 | 'controller' |
81 | 81 | ); |
82 | 82 | } |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | private function modelTraits() |
116 | 116 | { |
117 | 117 | return [ |
118 | - '\\' . Publishable::class, |
|
119 | - '\\' . Sortable::class, |
|
118 | + '\\'.Publishable::class, |
|
119 | + '\\'.Sortable::class, |
|
120 | 120 | 'q' => 'Proceed.', |
121 | 121 | ]; |
122 | 122 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | protected function publishFile($from, $to, $type) |
132 | 132 | { |
133 | 133 | if ($this->filesystem->exists($to) && !$this->option('force')) { |
134 | - if (!$this->confirm('File [' . $to . '] already exists? Overwrite this file?')) { |
|
134 | + if (!$this->confirm('File ['.$to.'] already exists? Overwrite this file?')) { |
|
135 | 135 | return; |
136 | 136 | } |
137 | 137 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | |
171 | 171 | $to = str_replace($this->dirs['base'], '', realpath($to)); |
172 | 172 | |
173 | - $this->line('<info>Copied ' . $type . '</info> <comment>[' . $from . ']</comment> <info>To</info> <comment>[' . $to . ']</comment>'); |
|
173 | + $this->line('<info>Copied '.$type.'</info> <comment>['.$from.']</comment> <info>To</info> <comment>['.$to.']</comment>'); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | protected function replacePlaceholders($content) |
@@ -188,17 +188,17 @@ discard block |
||
188 | 188 | |
189 | 189 | private function generateImportStatements(): string |
190 | 190 | { |
191 | - return collect(['\\' . Page::class]) |
|
192 | - ->map(function ($statement) { |
|
193 | - return 'use ' . $statement . ";\n "; |
|
191 | + return collect(['\\'.Page::class]) |
|
192 | + ->map(function($statement) { |
|
193 | + return 'use '.$statement.";\n "; |
|
194 | 194 | })->implode(''); |
195 | 195 | } |
196 | 196 | |
197 | 197 | private function generateTraitStatements(): string |
198 | 198 | { |
199 | 199 | return collect($this->chosenTraits) |
200 | - ->map(function ($statement) { |
|
201 | - return 'use ' . $statement . ";\n "; |
|
200 | + ->map(function($statement) { |
|
201 | + return 'use '.$statement.";\n "; |
|
202 | 202 | })->implode(''); |
203 | 203 | } |
204 | 204 | |
@@ -217,12 +217,12 @@ discard block |
||
217 | 217 | |
218 | 218 | // We make an estimated guess based on the project name. At Think Tomorrow, we |
219 | 219 | // have a src folder which is PSR-4 namespaced by the project name itself. |
220 | - return str_replace('\\\\', '\\', ucfirst(config('chief.domain.namespace', 'App')) . '\\' . ucfirst($this->plural)); |
|
220 | + return str_replace('\\\\', '\\', ucfirst(config('chief.domain.namespace', 'App')).'\\'.ucfirst($this->plural)); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | private function addToConfig($configKey, $value) |
224 | 224 | { |
225 | - $current_values = config('chief.' . $configKey); |
|
225 | + $current_values = config('chief.'.$configKey); |
|
226 | 226 | |
227 | 227 | if (is_array($current_values)) { |
228 | 228 | $value = array_merge($current_values, $value); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | // Find value - note: this regex does not work for nested arrays! |
239 | 239 | // Also creates array with the non-short syntax. |
240 | - $content = preg_replace('/[\'|"]' . $key . '[\'|"] ?=> ?(\[[^\]]*\]|[\'|"].*[\'|"])/', var_export($value, true), $content); |
|
240 | + $content = preg_replace('/[\'|"]'.$key.'[\'|"] ?=> ?(\[[^\]]*\]|[\'|"].*[\'|"])/', var_export($value, true), $content); |
|
241 | 241 | |
242 | 242 | file_put_contents($file, $content); |
243 | 243 | } |