Expand the data from an aggregate inspection recursively, providing useful data for
the produced view model

@param InspectionInterface $inspection

@return array|mixed[]|\Traversable
543881
protected function expandAggregateInspectionData(InspectionInterface $inspection)
    {
        if ($inspection instanceof AggregateInspection) {
            return array_map(
                function (InspectionInterface $inspection) {
                    return [
                        static::PARAM_INSPECTION       => $inspection,
                        static::PARAM_INSPECTION_DATA  => $this->expandAggregateInspectionData($inspection),
                        static::PARAM_INSPECTION_CLASS => get_class($inspection),
                    ];
                },
                $inspection->getInspectionData()
            );
        }

        return $inspection->getInspectionData();
    }
785408
public function getByCriteria(CriteriaInterface $criteria)
    {
        $this->model = $criteria->apply($this->model, $this);
        $results = $this->model->get();
        $this->resetModel();

        return $this->parserResult($results);
    }
890037
private function expandCriteriaParameters(Criteria $criteria)
    {
        $expression = $criteria->getWhereExpression();

        if ($expression === null) {
            return [];
        }

        $valueVisitor = new SqlValueVisitor();

        $valueVisitor->dispatch($expression);

        [, $types] = $valueVisitor->getParamsAndTypes();

        return $types;
    }
1098349
public static function findAllEntitiesByCriteria(array $criteria = [], array $exclude = []): array
    {
        $class = static::class;

        /** @var EntityRepository $obj_collection */
        $obj_collection = new $class();

        foreach ($criteria as $k => $v) {
            $obj_collection->addSimpleWhereField($k, $v);
        }

        foreach ($exclude as $k => $v) {
            $obj_collection->addWhereFieldIsNot($k, $v);
        }

        return $obj_collection->getAsArrayOfObjects();
    }
1292229
protected function _extractDirtyFields(EntityInterface $entity): array
    {
        $dirtyFields = [];
        $fields = array_keys($entity->toArray());
        $dirtyFields = $entity->extract($fields, true);
        unset($dirtyFields['modified']);

        return array_keys($dirtyFields);
    }
346675
private function getChildIds(ModelInterface $model)
    {
        if (null === ($childCollections = $model->getMeta($model::CHILD_COLLECTIONS))) {
            return [];
        }

        $ids = [ModelId::fromModel($model)->getSerialized()];

        $childIds = [];
        foreach ($childCollections as $collection) {
            foreach ($collection as $child) {
                $childIds[] = $this->getChildIds($child);
            }
        }

        return \array_merge($ids, ...$childIds);
    }
831883
private function recurseFolders(VolumeInterface $volume, ExtendedFolderInterface $folder)
    {
        $data = array();

        foreach ($volume->findFoldersByParentFolder($folder) as $subFolder) {
            if (!$this->isGranted('FOLDER_READ', $subFolder)) {
                // TODO: uncomment
                //continue;
            }

            $tmp = array(
                'id' => $subFolder->getId(),
                'site_id' => $volume->getId(),
                'text' => $subFolder->getName(),
                'leaf' => false, //!$subFolder->hasSubFolders(),
                'numChilds' => $volume->countFoldersByParentFolder($subFolder),
                'allowDrop' => true,
                'children' => $this->recurseFolders($volume, $subFolder),
            );

            if (!$tmp['numChilds']) {
                $tmp['expanded'] = true;
                $tmp['children'] = [];
            }

            $data[] = $tmp;
        }

        return $data;
    }
841349
public static function getImplementations(string $interfaceName) : array
    {
        return \array_filter(\get_declared_classes(), function($className) use ($interfaceName)
        {
            return self::implementsInterface($className, $interfaceName);
        });
    }
373256
public function getChildren(OperationContextInterface $context = null)
    {
        $context = $this->ensureContext($context);
        $children = $this->getBinding()->getNavigationService()->getChildren(
            $this->getRepositoryId(),
            $this->getId(),
            $context->getQueryFilterString(),
            $context->getOrderBy(),
            $context->isIncludeAllowableActions(),
            $context->getIncludeRelationships(),
            $context->getRenditionFilterString(),
            $context->isIncludePathSegments()
        );

        $result = [];
        $objectFactory = $this->getObjectFactory();
        foreach ($children->getObjects() as $objectData) {
            if ($objectData->getObject() !== null) {
                $result[] = $objectFactory->convertObject($objectData->getObject(), $context);
            }
        }

        return $result;
    }
785878
public function inspect(EventInterface $event)
    {
        if (! $event instanceof MvcEvent) {
            return new NullInspection();
        }

        $request = $event->getRequest();

        if (! $request instanceof RequestInterface) {
            return new NullInspection();
        }

        return new RequestInspection($request);
    }
221452
@SuppressWarnings("unchecked")
    public <T extends Inspection> T inspect(T inspection) {
        initializeSingleGroup();
        singleGroup.addInspections(inspection);
        WarpResult result = execute();
        return (T) result.getGroup(SingleInspectionSpecifier.GROUP_ID).getInspection();
    }
575735
public static <FACETEDTYPE extends Faceted<FACETTYPE>, FACETTYPE extends Facet<FACETEDTYPE>> Set<Class<FACETTYPE>> getAllOptionalFacets(
            final Class<FACETTYPE> inspectedType)
   {
      Set<Class<FACETTYPE>> seen = new LinkedHashSet<Class<FACETTYPE>>();
      return getAllRelatedFacets(seen, inspectedType, FacetConstraintType.OPTIONAL);
   }
206300
private function getCostCollection(OrderInterface $order) : Collection
    {
        if ($order->hasShippingMethod()) {
            $costs = $this->getCurrentShippingMethodCostsCollection($order);
            if ($costs->count() > 0) {
                return $costs;
            }
        }
        
        return $this->getShippingCostCollection($order);
    }
3019
private function resolveObjectExtensions(HasExtensionsInterface $objectDefinition): array
    {
        $extensions = [];

        //get all extensions registered as services
        $registeredExtensions = $this->container->get(ExtensionManager::class)->getExtensions();
        foreach ($registeredExtensions as $registeredExtension) {
            foreach ($objectDefinition->getExtensions() as $extensionDefinition) {
                $extensionClass = $extensionDefinition->getClass();
                if (\get_class($registeredExtension) === $extensionClass) {
                    $extensions[$extensionClass] = $registeredExtension;
                }
            }
        }

        //get all extensions not registered as services
        foreach ($objectDefinition->getExtensions() as $extensionDefinition) {
            $class = $extensionDefinition->getClass();
            if (!isset($extensions[$class])) {
                $instance = new $class();
                if ($instance instanceof ContainerAwareInterface) {
                    $instance->setContainer($this->container);
                }

                $extensions[$class] = $instance;
            }
        }

        return array_values($extensions);
    }
613467
public function inspect(EventInterface $event)
    {
        if (! $event instanceof MvcEvent) {
            return new NullInspection();
        }

        $response = $event->getResponse();

        if (! $response instanceof ResponseInterface) {
            return new NullInspection();
        }

        return new ResponseInspection($response);
    }
359720
public function visit($value, ?VisitorInterface $subVisitor = null)
    {
        if ($subVisitor === null) {
            throw new RuntimeException('Implementation requires sub-visitor');
        }

        return [
            'id' => $value->getId(),
            'definition_identifier' => $value->getDefinition()->getIdentifier(),
            'is_translatable' => $value->isTranslatable(),
            'is_always_available' => $value->isAlwaysAvailable(),
            'main_locale' => $value->getMainLocale(),
            'available_locales' => $value->getAvailableLocales(),
            'view_type' => $value->getViewType(),
            'item_view_type' => $value->getItemViewType(),
            'name' => $value->getName(),
            'placeholders' => iterator_to_array($this->visitPlaceholders($value, $subVisitor)),
            'parameters' => $this->visitParameters($value, $subVisitor),
            'configuration' => iterator_to_array($this->visitConfiguration($value, $subVisitor)),
            'collections' => iterator_to_array($this->visitCollections($value, $subVisitor)),
        ];
    }
1178757
public function inspect(EventInterface $event)
    {
        $tryPaths = [
            'composer.json',
            __DIR__ . '/../../../../../../../../composer.json',
        ];
        $composerJson          = [];
        $composerLockJson      = [];
        $composerInstalledJson = [];

        foreach ($tryPaths as $path) {
            if (! file_exists($path)) {
                continue;
            }

            $composerJson = $this->readAndParseJson($path);
            $lockPath     = dirname($path) . '/composer.lock';

            if (file_exists($lockPath)) {
                $composerLockJson = $this->readAndParseJson($lockPath);
            }

            break;
        }

        if (class_exists(ClassLoader::class)) {
            $reflectionClass = new ReflectionClass(ClassLoader::class);
            $installedPath   = dirname($reflectionClass->getFileName()) . '/installed.json';

            if (file_exists($installedPath)) {
                $composerInstalledJson = $this->readAndParseJson($installedPath);
            }
        }

        if (! $composerJson) {
            return new NullInspection();
        }

        return new ComposerInspection($composerJson, $composerLockJson, $composerInstalledJson);
    }