@@ -14,8 +14,8 @@ |
||
| 14 | 14 | public static function ownedBy(FragmentsOwner $owner): ?ContextModel |
| 15 | 15 | { |
| 16 | 16 | return static::where('owner_type', $owner->modelReference()->className()) |
| 17 | - ->where('owner_id', $owner->modelReference()->id()) |
|
| 18 | - ->first(); |
|
| 17 | + ->where('owner_id', $owner->modelReference()->id()) |
|
| 18 | + ->first(); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public static function createForOwner(FragmentsOwner $owner): ContextModel |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function renderFragment($owner, $loop, $fragments, $viewData): string |
| 23 | 23 | { |
| 24 | 24 | // Default (legacy) view rendering |
| 25 | - if(public_method_exists($this, 'renderView')) { |
|
| 25 | + if (public_method_exists($this, 'renderView')) { |
|
| 26 | 26 | return $this->renderView(); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | public function fragmentModel(): FragmentModel |
| 40 | 40 | { |
| 41 | - if(!isset($this->fragmentModel)) { |
|
| 41 | + if (!isset($this->fragmentModel)) { |
|
| 42 | 42 | throw new \DomainException('FragmentModel property on ['.get_class($this).'] expected to be set, but it\'s not.'); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $targetModel = Morphables::instance($targetUrlRecord->model_type)->find($targetUrlRecord->model_id); |
| 36 | 36 | |
| 37 | 37 | if (!$targetModel) { |
| 38 | - throw new ArchivedUrlException('Corrupt target model for this url request. Model by reference [' . $targetUrlRecord->model_type . '@' . $targetUrlRecord->model_id . '] has probably been archived or deleted.'); |
|
| 38 | + throw new ArchivedUrlException('Corrupt target model for this url request. Model by reference ['.$targetUrlRecord->model_type.'@'.$targetUrlRecord->model_id.'] has probably been archived or deleted.'); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return static::createRedirect($targetModel->url($locale)); |
@@ -45,14 +45,14 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | if (!$model) { |
| 48 | - throw new ArchivedUrlException('Corrupt target model for this url request. Model by reference [' . $urlRecord->model_type . '@' . $urlRecord->model_id . '] has probably been archived or deleted.'); |
|
| 48 | + throw new ArchivedUrlException('Corrupt target model for this url request. Model by reference ['.$urlRecord->model_type.'@'.$urlRecord->model_id.'] has probably been archived or deleted.'); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | if (public_method_exists($model, 'isPublished') && !$model->isPublished()) { |
| 52 | 52 | |
| 53 | 53 | /** When admin is logged in and this request is in preview mode, we allow the view */ |
| 54 | 54 | if (!PreviewMode::fromRequest()->check()) { |
| 55 | - throw new NotFoundHttpException('Model found for request [' . $slug . '] but it is not published.'); |
|
| 55 | + throw new NotFoundHttpException('Model found for request ['.$slug.'] but it is not published.'); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - throw new NotFoundHttpException('No url or model found for request [' . $slug . '] for locale [' . $locale . '].'); |
|
| 66 | + throw new NotFoundHttpException('No url or model found for request ['.$slug.'] for locale ['.$locale.'].'); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | private static function createRedirect(string $url) |
@@ -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 | |
@@ -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 ''; |