@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | $blockRepository->bulkDelete($object->blocks()->pluck('id')->toArray()); |
| 108 | - $this->getBlocks($object, $fields)->each(function ($block) use ($blockRepository) { |
|
| 108 | + $this->getBlocks($object, $fields)->each(function($block) use ($blockRepository) { |
|
| 109 | 109 | $this->createBlock($blockRepository, $block); |
| 110 | 110 | }); |
| 111 | 111 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $blockCreated = $blockRepository->create($blockFields); |
| 123 | 123 | |
| 124 | 124 | // Handle child blocks |
| 125 | - $blockFields['blocks']->each(function ($childBlock) use ($blockCreated, $blockRepository) { |
|
| 125 | + $blockFields['blocks']->each(function($childBlock) use ($blockCreated, $blockRepository) { |
|
| 126 | 126 | $childBlock['parent_id'] = $blockCreated->id; |
| 127 | 127 | $this->createBlock($blockRepository, $childBlock); |
| 128 | 128 | }); |
@@ -237,9 +237,9 @@ discard block |
||
| 237 | 237 | ]; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - $fields['blocksFields'][] = Collection::make($block['content'])->filter(function ($value, $key) { |
|
| 240 | + $fields['blocksFields'][] = Collection::make($block['content'])->filter(function($value, $key) { |
|
| 241 | 241 | return $key !== "browsers"; |
| 242 | - })->map(function ($value, $key) use ($block) { |
|
| 242 | + })->map(function($value, $key) use ($block) { |
|
| 243 | 243 | return [ |
| 244 | 244 | 'name' => "blocks[$block->id][$key]", |
| 245 | 245 | 'value' => $value, |
@@ -252,15 +252,15 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | if ($medias) { |
| 254 | 254 | if (config('twill.media_library.translated_form_fields', false)) { |
| 255 | - $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function ($mediasByLocale, $locale) use ($block) { |
|
| 256 | - return Collection::make($mediasByLocale)->mapWithKeys(function ($value, $key) use ($block, $locale) { |
|
| 255 | + $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function($mediasByLocale, $locale) use ($block) { |
|
| 256 | + return Collection::make($mediasByLocale)->mapWithKeys(function($value, $key) use ($block, $locale) { |
|
| 257 | 257 | return [ |
| 258 | 258 | "blocks[$block->id][$key][$locale]" => $value, |
| 259 | 259 | ]; |
| 260 | 260 | }); |
| 261 | 261 | })->filter()->toArray(); |
| 262 | 262 | } else { |
| 263 | - $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function ($value, $key) use ($block) { |
|
| 263 | + $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function($value, $key) use ($block) { |
|
| 264 | 264 | return [ |
| 265 | 265 | "blocks[$block->id][$key]" => $value, |
| 266 | 266 | ]; |
@@ -271,8 +271,8 @@ discard block |
||
| 271 | 271 | $files = $blockFormFields['files']; |
| 272 | 272 | |
| 273 | 273 | if ($files) { |
| 274 | - Collection::make($files)->each(function ($rolesWithFiles, $locale) use (&$fields, $block) { |
|
| 275 | - $fields['blocksFiles'][] = Collection::make($rolesWithFiles)->mapWithKeys(function ($files, $role) use ($locale, $block) { |
|
| 274 | + Collection::make($files)->each(function($rolesWithFiles, $locale) use (&$fields, $block) { |
|
| 275 | + $fields['blocksFiles'][] = Collection::make($rolesWithFiles)->mapWithKeys(function($files, $role) use ($locale, $block) { |
|
| 276 | 276 | return [ |
| 277 | 277 | "blocks[$block->id][$role][$locale]" => $files, |
| 278 | 278 | ]; |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | protected function getBlockBrowsers($block) |
| 313 | 313 | { |
| 314 | - return Collection::make($block['content']['browsers'])->mapWithKeys(function ($ids, $relation) use ($block) { |
|
| 314 | + return Collection::make($block['content']['browsers'])->mapWithKeys(function($ids, $relation) use ($block) { |
|
| 315 | 315 | if (Schema::hasTable(config('twill.related_table', 'twill_related')) && $block->getRelated($relation)->isNotEmpty()) { |
| 316 | 316 | $items = $this->getFormFieldsForRelatedBrowser($block, $relation); |
| 317 | 317 | foreach ($items as &$item) { |
@@ -342,9 +342,9 @@ discard block |
||
| 342 | 342 | $sortedRelatedItems[$item->id] = $item; |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - $items = Collection::make(array_values($sortedRelatedItems))->filter(function ($value) { |
|
| 345 | + $items = Collection::make(array_values($sortedRelatedItems))->filter(function($value) { |
|
| 346 | 346 | return is_object($value); |
| 347 | - })->map(function ($relatedElement) use ($relation) { |
|
| 347 | + })->map(function($relatedElement) use ($relation) { |
|
| 348 | 348 | return [ |
| 349 | 349 | 'id' => $relatedElement->id, |
| 350 | 350 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->title, |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | if (Schema::hasTable(config('twill.related_table', 'twill_related'))) { |
| 48 | 48 | $relatedItems = Collection::make(); |
| 49 | 49 | |
| 50 | - Collection::make($fields['browsers'])->each(function ($items, $browserName) use (&$relatedItems) { |
|
| 51 | - Collection::make($items)->each(function ($item) use ($browserName, &$relatedItems) { |
|
| 50 | + Collection::make($fields['browsers'])->each(function($items, $browserName) use (&$relatedItems) { |
|
| 51 | + Collection::make($items)->each(function($item) use ($browserName, &$relatedItems) { |
|
| 52 | 52 | try { |
| 53 | 53 | $repository = $this->getModelRepository($item['endpointType'] ?? $browserName); |
| 54 | 54 | $relatedItems->push((object) [ |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | if (Schema::hasTable(config('twill.related_table', 'twill_related'))) { |
| 78 | 78 | if (isset($fields['browsers'])) { |
| 79 | - Collection::make($fields['browsers'])->each(function ($items, $browserName) use ($object) { |
|
| 79 | + Collection::make($fields['browsers'])->each(function($items, $browserName) use ($object) { |
|
| 80 | 80 | $object->saveRelated($items, $browserName); |
| 81 | 81 | }); |
| 82 | 82 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $block['content'] = empty($block['content']) ? new \stdClass : (object) $block['content']; |
| 110 | 110 | |
| 111 | 111 | if ($block['browsers']) { |
| 112 | - $browsers = Collection::make($block['browsers'])->map(function ($items) { |
|
| 112 | + $browsers = Collection::make($block['browsers'])->map(function($items) { |
|
| 113 | 113 | return Collection::make($items)->pluck('id'); |
| 114 | 114 | })->toArray(); |
| 115 | 115 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | if (!function_exists('dumpUsableSqlQuery')) { |
| 11 | 11 | function dumpUsableSqlQuery($query) |
| 12 | 12 | { |
| 13 | - dd(vsprintf(str_replace('?', '%s', $query->toSql()), array_map(function ($binding) { |
|
| 13 | + dd(vsprintf(str_replace('?', '%s', $query->toSql()), array_map(function($binding) { |
|
| 14 | 14 | return is_numeric($binding) ? $binding : "'{$binding}'"; |
| 15 | 15 | }, $query->getBindings()))); |
| 16 | 16 | } |
@@ -202,12 +202,12 @@ discard block |
||
| 202 | 202 | { |
| 203 | 203 | $blockList = app(BlockCollection::class)->getBlockList(); |
| 204 | 204 | |
| 205 | - $appBlocksList = $blockList->filter(function (Block $block) { |
|
| 205 | + $appBlocksList = $blockList->filter(function(Block $block) { |
|
| 206 | 206 | return $block->source !== A17\Twill\Services\Blocks\Block::SOURCE_TWILL; |
| 207 | 207 | }); |
| 208 | 208 | |
| 209 | 209 | $finalBlockList = $blockList->filter( |
| 210 | - function (Block $block) use ($blocks, $groups, $appBlocksList) { |
|
| 210 | + function(Block $block) use ($blocks, $groups, $appBlocksList) { |
|
| 211 | 211 | if ($block->group === A17\Twill\Services\Blocks\Block::SOURCE_TWILL) { |
| 212 | 212 | if (!collect( |
| 213 | 213 | config('twill.block_editor.use_twill_blocks') |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | /** @var \Illuminate\Support\Collection<Block> $appBlocksList */ |
| 219 | 219 | if (count($appBlocksList) > 0 && $appBlocksList->contains( |
| 220 | - function ($appBlock) use ($block) { |
|
| 220 | + function($appBlock) use ($block) { |
|
| 221 | 221 | return $appBlock->name === $block->name; |
| 222 | 222 | }) |
| 223 | 223 | ) { |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | $this->getChildrenPreview($block['blocks'], $blocksCollection, $newBlock->id, $blockId, $blockRepository); |
| 54 | 54 | |
| 55 | 55 | $renderedBlocks = $blocksCollection->where('parent_id', null) |
| 56 | - ->map(function ($blockToRender) use ($block, $blocksCollection, $viewFactory, $config) { |
|
| 56 | + ->map(function($blockToRender) use ($block, $blocksCollection, $viewFactory, $config) { |
|
| 57 | 57 | try { |
| 58 | 58 | if ($config->get('twill.block_editor.block_preview_render_childs') ?? true) { |
| 59 | 59 | $childBlocks = $blocksCollection->where('parent_id', $blockToRender->id); |
| 60 | - $renderedChildViews = $childBlocks->map(function ($childBlock) use ($viewFactory, $config) { |
|
| 60 | + $renderedChildViews = $childBlocks->map(function($childBlock) use ($viewFactory, $config) { |
|
| 61 | 61 | $view = $this->getBlockView($childBlock->type, $config); |
| 62 | 62 | |
| 63 | 63 | return $viewFactory->exists($view) ? $viewFactory->make($view, [ |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | protected function getChildrenPreview($blocks, $blocksCollection, $parentId, &$blockId, $blockRepository) |
| 125 | 125 | { |
| 126 | - $blocks->each(function ($childBlock) use (&$blockId, $parentId, $blocksCollection, $blockRepository) { |
|
| 126 | + $blocks->each(function($childBlock) use (&$blockId, $parentId, $blocksCollection, $blockRepository) { |
|
| 127 | 127 | $childBlock['parent_id'] = $parentId; |
| 128 | 128 | $blockId++; |
| 129 | 129 | $newChildBlock = $blockRepository->createForPreview($childBlock); |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | "$this->viewPrefix.index", |
| 363 | 363 | "twill::$this->moduleName.index", |
| 364 | 364 | "twill::layouts.listing", |
| 365 | - ])->first(function ($view) { |
|
| 365 | + ])->first(function($view) { |
|
| 366 | 366 | return View::exists($view); |
| 367 | 367 | }); |
| 368 | 368 | |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | "$this->viewPrefix.form", |
| 472 | 472 | "twill::$this->moduleName.form", |
| 473 | 473 | "twill::layouts.form", |
| 474 | - ])->first(function ($view) { |
|
| 474 | + ])->first(function($view) { |
|
| 475 | 475 | return View::exists($view); |
| 476 | 476 | }); |
| 477 | 477 | |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | "$this->viewPrefix.form", |
| 503 | 503 | "twill::$this->moduleName.form", |
| 504 | 504 | "twill::layouts.form", |
| 505 | - ])->first(function ($view) { |
|
| 505 | + ])->first(function($view) { |
|
| 506 | 506 | return View::exists($view); |
| 507 | 507 | }); |
| 508 | 508 | |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | "$this->viewPrefix.form", |
| 631 | 631 | "twill::$this->moduleName.form", |
| 632 | 632 | "twill::layouts.form", |
| 633 | - ])->first(function ($view) { |
|
| 633 | + ])->first(function($view) { |
|
| 634 | 634 | return View::exists($view); |
| 635 | 635 | }); |
| 636 | 636 | |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | $query = $this->request->input('q'); |
| 893 | 893 | $tags = $this->repository->getTags($query); |
| 894 | 894 | |
| 895 | - return Response::json(['items' => $tags->map(function ($tag) { |
|
| 895 | + return Response::json(['items' => $tags->map(function($tag) { |
|
| 896 | 896 | return $tag->name; |
| 897 | 897 | })], 200); |
| 898 | 898 | } |
@@ -989,8 +989,8 @@ discard block |
||
| 989 | 989 | protected function getIndexTableData($items) |
| 990 | 990 | { |
| 991 | 991 | $translated = $this->moduleHas('translations'); |
| 992 | - return $items->map(function ($item) use ($translated) { |
|
| 993 | - $columnsData = Collection::make($this->indexColumns)->mapWithKeys(function ($column) use ($item) { |
|
| 992 | + return $items->map(function($item) use ($translated) { |
|
| 993 | + $columnsData = Collection::make($this->indexColumns)->mapWithKeys(function($column) use ($item) { |
|
| 994 | 994 | return $this->getItemColumnData($item, $column); |
| 995 | 995 | })->toArray(); |
| 996 | 996 | |
@@ -1266,7 +1266,7 @@ discard block |
||
| 1266 | 1266 | 'feature', |
| 1267 | 1267 | 'bulkFeature', |
| 1268 | 1268 | 'bulkDelete', |
| 1269 | - ])->mapWithKeys(function ($endpoint) { |
|
| 1269 | + ])->mapWithKeys(function($endpoint) { |
|
| 1270 | 1270 | return [ |
| 1271 | 1271 | $endpoint . 'Url' => $this->getIndexOption($endpoint) ? moduleRoute( |
| 1272 | 1272 | $this->moduleName, |
@@ -1284,7 +1284,7 @@ discard block |
||
| 1284 | 1284 | */ |
| 1285 | 1285 | protected function getIndexOption($option) |
| 1286 | 1286 | { |
| 1287 | - return once(function () use ($option) { |
|
| 1287 | + return once(function() use ($option) { |
|
| 1288 | 1288 | $customOptionNamesMapping = [ |
| 1289 | 1289 | 'store' => 'create', |
| 1290 | 1290 | ]; |
@@ -1341,8 +1341,8 @@ discard block |
||
| 1341 | 1341 | { |
| 1342 | 1342 | $withImage = $this->moduleHas('medias'); |
| 1343 | 1343 | |
| 1344 | - return $items->map(function ($item) use ($withImage) { |
|
| 1345 | - $columnsData = Collection::make($this->browserColumns)->mapWithKeys(function ($column) use ($item) { |
|
| 1344 | + return $items->map(function($item) use ($withImage) { |
|
| 1345 | + $columnsData = Collection::make($this->browserColumns)->mapWithKeys(function($column) use ($item) { |
|
| 1346 | 1346 | return $this->getItemColumnData($item, $column); |
| 1347 | 1347 | })->toArray(); |
| 1348 | 1348 | |
@@ -1408,7 +1408,7 @@ discard block |
||
| 1408 | 1408 | $fieldSplitted = explode('|', $field); |
| 1409 | 1409 | if (count($fieldSplitted) > 1) { |
| 1410 | 1410 | $requestValue = $requestFilters[$key]; |
| 1411 | - Collection::make($fieldSplitted)->each(function ($scopeKey) use (&$scope, $requestValue) { |
|
| 1411 | + Collection::make($fieldSplitted)->each(function($scopeKey) use (&$scope, $requestValue) { |
|
| 1412 | 1412 | $scope[$scopeKey] = $requestValue; |
| 1413 | 1413 | }); |
| 1414 | 1414 | } else { |
@@ -1586,11 +1586,11 @@ discard block |
||
| 1586 | 1586 | */ |
| 1587 | 1587 | protected function validateFormRequest() |
| 1588 | 1588 | { |
| 1589 | - $unauthorizedFields = Collection::make($this->fieldsPermissions)->filter(function ($permission, $field) { |
|
| 1589 | + $unauthorizedFields = Collection::make($this->fieldsPermissions)->filter(function($permission, $field) { |
|
| 1590 | 1590 | return Auth::guard('twill_users')->user()->cannot($permission); |
| 1591 | 1591 | })->keys(); |
| 1592 | 1592 | |
| 1593 | - $unauthorizedFields->each(function ($field) { |
|
| 1593 | + $unauthorizedFields->each(function($field) { |
|
| 1594 | 1594 | $this->request->offsetUnset($field); |
| 1595 | 1595 | }); |
| 1596 | 1596 | |
@@ -1642,7 +1642,7 @@ discard block |
||
| 1642 | 1642 | $singularName = Str::singular($name); |
| 1643 | 1643 | $modelClass = config('twill.namespace') . '\\Models\\' . Str::studly($singularName); |
| 1644 | 1644 | |
| 1645 | - if(!class_exists($modelClass)) { |
|
| 1645 | + if (!class_exists($modelClass)) { |
|
| 1646 | 1646 | $modelClass = $this->getCapsuleByModule($name)['model']; |
| 1647 | 1647 | } |
| 1648 | 1648 | |
@@ -1896,7 +1896,7 @@ discard block |
||
| 1896 | 1896 | */ |
| 1897 | 1897 | public function getRepeaterList() |
| 1898 | 1898 | { |
| 1899 | - return app(BlockCollection::class)->getRepeaterList()->mapWithKeys(function (Block $repeater) { |
|
| 1899 | + return app(BlockCollection::class)->getRepeaterList()->mapWithKeys(function(Block $repeater) { |
|
| 1900 | 1900 | return [$repeater->name => $repeater->toList()]; |
| 1901 | 1901 | }); |
| 1902 | 1902 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $this->blockCollection |
| 49 | 49 | ->getMissingDirectories() |
| 50 | - ->each(function ($directory) { |
|
| 50 | + ->each(function($directory) { |
|
| 51 | 51 | $this->error("Directory not found: {$directory}"); |
| 52 | 52 | }); |
| 53 | 53 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | return $blockCollection |
| 62 | 62 | ->first() |
| 63 | 63 | ->keys() |
| 64 | - ->map(function ($key) { |
|
| 64 | + ->map(function($key) { |
|
| 65 | 65 | return Str::studly($key); |
| 66 | 66 | }) |
| 67 | 67 | ->toArray(); |
@@ -81,15 +81,15 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | return $this->blockCollection |
| 83 | 83 | ->collect() |
| 84 | - ->reject(function (Block $block) use ($sourceFiltered) { |
|
| 84 | + ->reject(function(Block $block) use ($sourceFiltered) { |
|
| 85 | 85 | return $sourceFiltered && !$this->option($block->source); |
| 86 | 86 | }) |
| 87 | - ->reject(function (Block $block) use ($typeFiltered) { |
|
| 87 | + ->reject(function(Block $block) use ($typeFiltered) { |
|
| 88 | 88 | return $this->dontPassTextFilter($block) || |
| 89 | 89 | ($typeFiltered && |
| 90 | 90 | !$this->option(Str::plural($block->type))); |
| 91 | 91 | }) |
| 92 | - ->map(function (Block $block) { |
|
| 92 | + ->map(function(Block $block) { |
|
| 93 | 93 | $data = $this->colorize( |
| 94 | 94 | $this->option('short') ? $block->toShortList() : $block->toList() |
| 95 | 95 | ); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | unset($data['rules'], $data['rulesForTranslatedFields']); |
| 98 | 98 | return $data; |
| 99 | 99 | }) |
| 100 | - ->sortBy(function ($block) { |
|
| 100 | + ->sortBy(function($block) { |
|
| 101 | 101 | return [$block['group'], $block['title']]; |
| 102 | 102 | }); |
| 103 | 103 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | if (filled($filter = $this->argument('filter'))) { |
| 156 | 156 | return !$block |
| 157 | 157 | ->toList() |
| 158 | - ->reduce(function ($keep, $element) use ($filter) { |
|
| 158 | + ->reduce(function($keep, $element) use ($filter) { |
|
| 159 | 159 | if (is_array($element)) { |
| 160 | 160 | return false; |
| 161 | 161 | } |
@@ -272,15 +272,15 @@ discard block |
||
| 272 | 272 | $this->isNewFormat = $this->isNewFormat($contents); |
| 273 | 273 | $this->contents = $contents; |
| 274 | 274 | |
| 275 | - $this->parseArrayProperty('ValidationRules', $contents, $this->name, function ($value) { |
|
| 275 | + $this->parseArrayProperty('ValidationRules', $contents, $this->name, function($value) { |
|
| 276 | 276 | $this->rules = $value ?? $this->rules; |
| 277 | 277 | }); |
| 278 | 278 | |
| 279 | - $this->parseArrayProperty('ValidationRulesForTranslatedFields', $contents, $this->name, function ($value) { |
|
| 279 | + $this->parseArrayProperty('ValidationRulesForTranslatedFields', $contents, $this->name, function($value) { |
|
| 280 | 280 | $this->rulesForTranslatedFields = $value ?? $this->rulesForTranslatedFields; |
| 281 | 281 | }); |
| 282 | 282 | |
| 283 | - $this->parseMixedProperty('titleField', $contents, $this->name, function ($value, $options) { |
|
| 283 | + $this->parseMixedProperty('titleField', $contents, $this->name, function($value, $options) { |
|
| 284 | 284 | $this->titleField = $value; |
| 285 | 285 | $this->hideTitlePrefix = (boolean) ($options['hidePrefix'] ?? false); |
| 286 | 286 | }); |
@@ -423,14 +423,14 @@ discard block |
||
| 423 | 423 | return $value; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - if ($configBlock = collect(config("twill.block_editor.blocks"))->filter(function ($block) use ($blockName) { |
|
| 426 | + if ($configBlock = collect(config("twill.block_editor.blocks"))->filter(function($block) use ($blockName) { |
|
| 427 | 427 | return Str::contains($block['component'], $blockName); |
| 428 | 428 | })->first()) { |
| 429 | 429 | if ($value = ($configBlock[$property] ?? null)) { |
| 430 | 430 | return $value; |
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | - if ($configRepeater = collect(config("twill.block_editor.repeaters"))->filter(function ($repeater) use ($blockName) { |
|
| 433 | + if ($configRepeater = collect(config("twill.block_editor.repeaters"))->filter(function($repeater) use ($blockName) { |
|
| 434 | 434 | return Str::contains($repeater['component'], $blockName); |
| 435 | 435 | })->first()) { |
| 436 | 436 | if ($value = ($configRepeater[$property] ?? null)) { |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | public function findByName($search, $sources = []) |
| 53 | 53 | { |
| 54 | 54 | return $this->collect() |
| 55 | - ->filter(function ($block) use ($search, $sources) { |
|
| 55 | + ->filter(function($block) use ($search, $sources) { |
|
| 56 | 56 | return $block->name == $search && |
| 57 | 57 | (blank($sources) || |
| 58 | 58 | collect($sources)->contains($block->source)); |
| 59 | 59 | }) |
| 60 | - ->sortBy(function ($block) { |
|
| 60 | + ->sortBy(function($block) { |
|
| 61 | 61 | return $block->source === 'app' ? 0 : 1; |
| 62 | 62 | }) |
| 63 | 63 | ->first(); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | public function getBlocks() |
| 70 | 70 | { |
| 71 | 71 | return $this->collect() |
| 72 | - ->filter(function ($block) { |
|
| 72 | + ->filter(function($block) { |
|
| 73 | 73 | return $block->type === Block::TYPE_BLOCK; |
| 74 | 74 | }) |
| 75 | 75 | ->values(); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | return collect($this->fileSystem->files($directory)) |
| 109 | - ->map(function ($file) use ($source, $type) { |
|
| 109 | + ->map(function($file) use ($source, $type) { |
|
| 110 | 110 | return Block::make($file, $type, $source); |
| 111 | 111 | }); |
| 112 | 112 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $this->paths = collect( |
| 120 | 120 | config('twill.block_editor.directories.source.blocks') |
| 121 | 121 | ) |
| 122 | - ->map(function ($path) { |
|
| 122 | + ->map(function($path) { |
|
| 123 | 123 | $path['type'] = Block::TYPE_BLOCK; |
| 124 | 124 | |
| 125 | 125 | return $path; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | ->merge( |
| 128 | 128 | collect( |
| 129 | 129 | config('twill.block_editor.directories.source.repeaters') |
| 130 | - )->map(function ($path) { |
|
| 130 | + )->map(function($path) { |
|
| 131 | 131 | $path['type'] = Block::TYPE_REPEATER; |
| 132 | 132 | |
| 133 | 133 | return $path; |
@@ -165,12 +165,12 @@ discard block |
||
| 165 | 165 | $this->generatePaths(); |
| 166 | 166 | |
| 167 | 167 | $this->items = collect($this->paths) |
| 168 | - ->reduce(function (Collection $keep, $path) { |
|
| 168 | + ->reduce(function(Collection $keep, $path) { |
|
| 169 | 169 | $this->readBlocks( |
| 170 | 170 | $path['path'], |
| 171 | 171 | $path['source'], |
| 172 | 172 | $path['type'] |
| 173 | - )->each(function ($block) use ($keep) { |
|
| 173 | + )->each(function($block) use ($keep) { |
|
| 174 | 174 | $keep->push($block); |
| 175 | 175 | |
| 176 | 176 | return $keep; |
@@ -181,15 +181,15 @@ discard block |
||
| 181 | 181 | ->toArray(); |
| 182 | 182 | |
| 183 | 183 | $this->items = $this->collect() |
| 184 | - ->each(function (Block $block) { |
|
| 184 | + ->each(function(Block $block) { |
|
| 185 | 185 | $block->setSource($this->detectCustomSources($block)); |
| 186 | 186 | }) |
| 187 | 187 | ->toArray(); |
| 188 | 188 | |
| 189 | 189 | // remove duplicate Twill blocks |
| 190 | 190 | $appBlocks = $this->collect()->whereIn('source', [Block::SOURCE_APP, Block::SOURCE_CUSTOM]); |
| 191 | - $this->items = $this->collect()->filter(function ($item) use ($appBlocks) { |
|
| 192 | - return !$appBlocks->contains(function ($block) use ($item) { |
|
| 191 | + $this->items = $this->collect()->filter(function($item) use ($appBlocks) { |
|
| 192 | + return !$appBlocks->contains(function($block) use ($item) { |
|
| 193 | 193 | return $item->source === Block::SOURCE_TWILL && $item->name === $block->name; |
| 194 | 194 | }); |
| 195 | 195 | })->values()->toArray(); |
@@ -212,12 +212,12 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | public function addBlocksFromConfig(Collection $items, $type) |
| 214 | 214 | { |
| 215 | - $items->reject(function ($value, $blockName) use ($type) { |
|
| 216 | - return $this->contains(function ($block) use ($blockName, $type) { |
|
| 215 | + $items->reject(function($value, $blockName) use ($type) { |
|
| 216 | + return $this->contains(function($block) use ($blockName, $type) { |
|
| 217 | 217 | return $block->name === $blockName && $block->type === $type; |
| 218 | 218 | }) ? [$blockName, $value] : false; |
| 219 | 219 | }) |
| 220 | - ->each(function ($block, $blockName) use ($type) { |
|
| 220 | + ->each(function($block, $blockName) use ($type) { |
|
| 221 | 221 | if ($block['compiled'] ?? false) { |
| 222 | 222 | $file = null; |
| 223 | 223 | } else { |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | public function logDeprecatedBlockConfig($blockName, $type) |
| 258 | 258 | { |
| 259 | - $path = $this->paths->filter(function ($path) use ($type) { |
|
| 259 | + $path = $this->paths->filter(function($path) use ($type) { |
|
| 260 | 260 | return $path['source'] === Block::SOURCE_APP && $path['type'] === $type; |
| 261 | 261 | })->pluck('path')->join(', ', ' or '); |
| 262 | 262 | |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | public function findFileByComponentName($componentName) |
| 279 | 279 | { |
| 280 | 280 | $filename = str_replace('a17-block-', '', $componentName) . '.blade.php'; |
| 281 | - $paths = $this->paths->pluck('path')->filter(function ($path) { |
|
| 281 | + $paths = $this->paths->pluck('path')->filter(function($path) { |
|
| 282 | 282 | return $this->fileSystem->exists($path); |
| 283 | 283 | })->toArray(); |
| 284 | 284 | |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | public function list() |
| 306 | 306 | { |
| 307 | - return $this->collect()->map(function (Block $block) { |
|
| 307 | + return $this->collect()->map(function(Block $block) { |
|
| 308 | 308 | return $block->toList(); |
| 309 | 309 | }); |
| 310 | 310 | } |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | public function getRepeaters() |
| 324 | 324 | { |
| 325 | 325 | return $this->collect() |
| 326 | - ->filter(function ($block) { |
|
| 326 | + ->filter(function($block) { |
|
| 327 | 327 | return $block->type === Block::TYPE_REPEATER; |
| 328 | 328 | }) |
| 329 | 329 | ->values(); |
@@ -23,17 +23,17 @@ |
||
| 23 | 23 | public function renderNamedBlocks($name = 'default', $renderChilds = true, $blockViewMappings = [], $data = []) |
| 24 | 24 | { |
| 25 | 25 | return $this->blocks |
| 26 | - ->filter(function ($block) use ($name) { |
|
| 26 | + ->filter(function($block) use ($name) { |
|
| 27 | 27 | return $name === 'default' |
| 28 | 28 | ? ($block->editor_name === $name || $block->editor_name === null) |
| 29 | 29 | : $block->editor_name === $name; |
| 30 | 30 | }) |
| 31 | 31 | ->where('parent_id', null) |
| 32 | - ->map(function ($block) use ($blockViewMappings, $renderChilds, $data) { |
|
| 32 | + ->map(function($block) use ($blockViewMappings, $renderChilds, $data) { |
|
| 33 | 33 | if ($renderChilds) { |
| 34 | 34 | $childBlocks = $this->blocks->where('parent_id', $block->id); |
| 35 | 35 | |
| 36 | - $renderedChildViews = $childBlocks->map(function ($childBlock) use ($blockViewMappings, $data) { |
|
| 36 | + $renderedChildViews = $childBlocks->map(function($childBlock) use ($blockViewMappings, $data) { |
|
| 37 | 37 | $class = BlockConfig::getForType($childBlock->type); |
| 38 | 38 | $view = $class->getBlockView($blockViewMappings); |
| 39 | 39 | $data = $class->getData($data, $childBlock); |