Command/CleanAssetsCommand.php
protected function computeFileSystemDifferences()
    {
        $entityPathByFilesystems = [];
        foreach ($this->resourceManager->getResourceConfigurations() as $resourceConfiguration) {
            $className = $resourceConfiguration->getEntity();
            $entityManager = $this->doctrine->getManagerForClass($className);
            if (!$entityManager instanceof EntityManagerInterface) {
                throw new \UnexpectedValueException("No manager found for class {$className}");
            }
            $repository = $entityManager->getRepository($className);
            if (!$repository instanceof ResourceRepositoryInterface) {
                throw new \UnexpectedValueException(
                    "Repository for class {$className} must implement ResourceRepositoryInterface"
                );
            }

            $paths = $repository->getPaths();
            $adapterReference = $this->adaptersByResourceType[$resourceConfiguration->getCode()];
            if (array_key_exists($adapterReference, $entityPathByFilesystems)) {
                /** @noinspection SlowArrayOperationsInLoopInspection */
                $entityPathByFilesystems[$adapterReference] = array_merge(
                    $entityPathByFilesystems[$adapterReference],
                    $paths
                );
            } else {
                $entityPathByFilesystems[$adapterReference] = $paths;
            }
        }

        foreach ($this->adapters as $adapterReference => $adapter) {
            $existingPaths = [];
            foreach ($adapter->listContents() as $metadata) {
                $entityPath = $metadata['path'];
                if ('.gitkeep' === $entityPath) {
                    continue;
                }
                $existingPaths[$entityPath] = $entityPath;
            }
            $entityPaths = $entityPathByFilesystems[$adapterReference];
            $this->extraFiles[$adapterReference] = array_diff_key($existingPaths, $entityPaths);
            $this->missingFiles[$adapterReference] = array_diff_key($entityPaths, $existingPaths);
        }
    }
protected function computeFileSystemDifferences()
    {
        $entityPathByFilesystems = [];
        foreach ($this->resourceManager->getResourceConfigurations() as $resourceConfiguration) {
            $className = $resourceConfiguration->getEntity();
            $entityManager = $this->doctrine->getManagerForClass($className);
            if (!$entityManager instanceof EntityManagerInterface) {
                throw new \UnexpectedValueException("No manager found for class {$className}");
            }
            $repository = $entityManager->getRepository($className);
            if (!$repository instanceof ResourceRepositoryInterface) {
                throw new \UnexpectedValueException(
                    "Repository for class {$className} must implement ResourceRepositoryInterface"
                );
            }

            $paths = $repository->getPaths();
            $adapterReference = $this->adaptersByResourceType[$resourceConfiguration->getCode()];
            if (array_key_exists($adapterReference, $entityPathByFilesystems)) {
                /** @noinspection SlowArrayOperationsInLoopInspection */
                $entityPathByFilesystems[$adapterReference] = array_merge(
                    $entityPathByFilesystems[$adapterReference],
                    $paths
                );
            } else {
                $entityPathByFilesystems[$adapterReference] = $paths;
            }
        }

        foreach ($this->adapters as $adapterReference => $adapter) {
            $existingPaths = [];
            foreach ($adapter->listContents() as $metadata) {
                $entityPath = $metadata['path'];
                if ('.gitkeep' === $entityPath) {
                    continue;
                }
                $existingPaths[$entityPath] = $entityPath;
            }
            $entityPaths = $entityPathByFilesystems[$adapterReference];
            $this->extraFiles[$adapterReference] = array_diff_key($existingPaths, $entityPaths);
            $this->missingFiles[$adapterReference] = array_diff_key($entityPaths, $existingPaths);
        }
    }
Compute de differences between what's in the storage system and what's in the database

@throws \UnexpectedValueException