| Conditions | 8 |
| Paths | 12 |
| Total Lines | 60 |
| Code Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php declare(strict_types=1); |
||
| 42 | public function load( |
||
| 43 | Request $request, |
||
| 44 | Criteria $criteria, |
||
| 45 | SalesChannelContext $context, |
||
| 46 | ?array $config = null, |
||
| 47 | ?ResolverContext $resolverContext = null |
||
| 48 | ): EntitySearchResult { |
||
| 49 | $this->eventDispatcher->dispatch(new CmsPageLoaderCriteriaEvent($request, $criteria, $context)); |
||
| 50 | $config ??= []; |
||
| 51 | |||
| 52 | // ensure sections, blocks and slots are loaded, slots and blocks can be restricted by caller |
||
| 53 | $criteria->addAssociation('sections.backgroundMedia'); |
||
| 54 | $criteria->addAssociation('sections.blocks.backgroundMedia'); |
||
| 55 | $criteria->addAssociation('sections.blocks.slots'); |
||
| 56 | |||
| 57 | // step 1, load cms pages with blocks and slots |
||
| 58 | $result = $this->cmsPageRepository->search($criteria, $context->getContext()); |
||
| 59 | $pages = $result->getEntities(); |
||
| 60 | |||
| 61 | foreach ($pages as $page) { |
||
| 62 | if ($page->getSections() === null) { |
||
| 63 | continue; |
||
| 64 | } |
||
| 65 | |||
| 66 | $page->getSections()->sort(fn (CmsSectionEntity $a, CmsSectionEntity $b) => $a->getPosition() <=> $b->getPosition()); |
||
| 67 | |||
| 68 | if (!$resolverContext) { |
||
| 69 | $resolverContext = new ResolverContext($context, $request); |
||
| 70 | } |
||
| 71 | |||
| 72 | // step 2, sort blocks into sectionPositions |
||
| 73 | foreach ($page->getSections() as $section) { |
||
| 74 | $blocks = $section->getBlocks(); |
||
| 75 | if ($blocks === null) { |
||
| 76 | continue; |
||
| 77 | } |
||
| 78 | $blocks->sort(fn (CmsBlockEntity $a, CmsBlockEntity $b) => $a->getPosition() <=> $b->getPosition()); |
||
| 79 | |||
| 80 | foreach ($blocks as $block) { |
||
| 81 | $slots = $block->getSlots(); |
||
| 82 | if ($slots === null) { |
||
| 83 | continue; |
||
| 84 | } |
||
| 85 | $slots->sort(fn (CmsSlotEntity $a, CmsSlotEntity $b) => $a->getSlot() <=> $b->getSlot()); |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | // step 3, find config overwrite |
||
| 90 | $overwrite = $config[$page->getId()] ?? $config; |
||
| 91 | |||
| 92 | // step 4, overwrite slot config |
||
| 93 | $this->overwriteSlotConfig($page, $overwrite); |
||
| 94 | |||
| 95 | // step 5, resolve slot data |
||
| 96 | $this->loadSlotData($page, $resolverContext); |
||
| 97 | } |
||
| 98 | |||
| 99 | $this->eventDispatcher->dispatch(new CmsPageLoadedEvent($request, $pages, $context)); |
||
| 100 | |||
| 101 | return $result; |
||
| 102 | } |
||
| 151 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths