Checks if the PackageStorage has been previously initialized with symlinks
and clears them. Otherwise the original sources would be overwritten.

@param StorageInterface $storage
@return void
182512
protected function checkAndRemovePackageSymlinks(StorageInterface $storage)
    {
        if (!$storage instanceof PackageStorage) {
            return;
        }
        foreach ($storage->getPublicResourcePaths() as $packageKey => $path) {
            $targetPathAndFilename = $this->path . $packageKey;
            if (Files::is_link($targetPathAndFilename)) {
                Files::unlink($targetPathAndFilename);
            }
        }
    }
69654
protected static function isAsset(PackageInterface $package)
    {
        foreach (Assets::getTypes() as $type) {
            $type = Assets::createType($type);

            if ($package->getType() === $type->getComposerType()) {
                return true;
            }
        }

        return false;
    }
82945
protected function checkStorageId($path, Storage $storage, StorageRepository $rep)
    {
        if (!file_exists($path.StorageListener::ID_FILE)) {
            // path is free. reserve for me
            file_put_contents($path.StorageListener::ID_FILE, $storage->getId());
        } elseif (file_get_contents($path.StorageListener::ID_FILE) == $storage->getId()) {
            // it is my path. do nothing
        } elseif (!($duplicate = $rep->find(file_get_contents($path.StorageListener::ID_FILE)))) {
            // this path is reserved storage that was removed and now this path is free
            file_put_contents($path.StorageListener::ID_FILE, $storage->getId());
        } else {
            return $duplicate;
        }

        return true;
    }
927325
public function deleteAction(Storage $storage)
    {
        $em = $this->getDoctrine()->getManager();
        $em->remove($storage);
        $em->flush();

        return $this->redirect($this->generateUrl('storage_list'));
    }
202393
protected function initialize($storage)
    {
        $this->parameters[self::PARAMETER_SMALLEST_IMAGE] = $storage->getImageSet()->getSmallestImageSet();
        $this->parameters[self::PARAMETER_CMS_PREFIX] = '';

        $this->parameters[self::PARAMETER_DOCUMENT_TYPE] = $this->storage->getDocumentTypes()->getDocumentTypeBySlug($this->documentType,
            true);
        $this->parameters[self::PARAMETER_DOCUMENT_TYPES] = $this->storage->getDocumentTypes()->getDocumentTypes();
        $this->parameters[self::PARAMETER_HIDE_TITLE_AND_STATE] = true;
        $this->parameters[self::PARAMETER_FORM_ID] = $this->formId;
    }
970181
protected function installLoader(PackageInterface $package)
    {
        $source = $this->getLoaderFilePackagePath($package);
        $target = $this->getLoaderFileInstallPath($package);

        copy($source, $target);
    }
1045607
public function removeAll(self $storage)
    {
        foreach ($this->data as $key => $value) {
            foreach ($storage->data as $object) {
                if ($object === $value) {
                    unset($this->data[$key]);
                    unset($this->info[$key]);
                }
            }
        }
    }
700257
public function onPreDelete(StorageEvent $event)
    {
        $entity = $event->getContent();
        if (!$entity instanceof Entity\Content) {
            return;
        }
        $taxonomies = $entity->getTaxonomy();
        if ($taxonomies instanceof Collection\Taxonomy) {
            $repo = $this->em->getRepository(Entity\Taxonomy::class);
            foreach ($taxonomies as $taxonomy) {
                $repo->delete($taxonomy);
            }
        }
        $relations = $entity->getRelation();
        if ($relations instanceof Collection\Relations) {
            $repo = $this->em->getRepository(Entity\Relations::class);
            foreach ($relations as $relation) {
                $repo->delete($relation);
            }
        }
    }
970830
public function rollback(ContainerInterface $container): void
    {
        foreach ($this->getRollbacks($container) as $class) {
            assert(is_string($class));
            $this->getIO()->writeInfo("Starting rollback for `$class`..." . PHP_EOL, IoInterface::VERBOSITY_VERBOSE);
            if (($migration = $this->createMigration($class, $container)) !== null) {
                $migration->init($container)->rollback();
                $this->getIO()->writeInfo("Rollback finished for `$class`." . PHP_EOL, IoInterface::VERBOSITY_NORMAL);
            }
        }

        $manager = $this->getConnection($container)->getSchemaManager();
        if ($manager->tablesExist([static::MIGRATIONS_TABLE]) === true) {
            $manager->dropTable(static::MIGRATIONS_TABLE);
        }
        if ($manager->tablesExist([static::SEEDS_TABLE]) === true) {
            $manager->dropTable(static::SEEDS_TABLE);
        }
    }
1209102
public function cleanUpFolders(ApplicationInterface $application)
    {

        // load the directories we want to clean-up on appserver restart
        $cleanUpFolders = array(new \SplFileInfo($application->getCacheDir()));

        // clean-up the directories
        foreach ($cleanUpFolders as $cleanUpFolder) {
            $this->cleanUpDir($cleanUpFolder);
        }
    }
1195291
public static function forget(string $key, string $storage = 'global'): void
    {
        $fileKey = self::key($key);
        if (self::has($key)) {
            @unlink(self::$path . '/' . $storage . '/' . $fileKey);
        }
    }
938042
public function restore(ContainerInterface $container, array $dump)
    {
        $this->bundleInfos = $dump['bundleInfos'];

        $this->isRestored = true;
    }
914695
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
    {
        if (false === parent::isInstalled($repo, $package)) {
            return false;
        }

        $targetRoot = $this->getContaoRoot();

        foreach ($this->getSources($package) as $targetPath) {
            if (!file_exists($this->filesystem->normalizePath($targetRoot . '/' . $targetPath))) {
                return false;
            }
        }

        return true;
    }
210988
public function cleanupPackages(Storage $storage, callable $callback = null)
    {
        $count = 0;
        $storageNode = $storage->node();
        $query = new FlowQuery([$storageNode]);
        $query = $query->find('[instanceof Neos.MarketPlace:Package]');
        $upstreamPackages = $this->getProcessedPackages();
        foreach ($query as $package) {
            /** @var NodeInterface $package */
            if (in_array($package->getProperty('title'), $upstreamPackages)) {
                continue;
            }
            $package->remove();
            if ($callback !== null) {
                $callback($package);
            }
            $this->emitPackageDeleted($package);
            $count++;
        }
        return $count;
    }
574729
public void init(IPersistentSubscriptionStore storageService) {
        Log.debug("init invoked");

        m_storageService = storageService;

        //reload any subscriptions persisted
        if (Log.DEBUG) {
            Log.debug("Reloading all stored subscriptions...subscription tree before {}", dumpTree());
        }
        
        for (Subscription subscription : m_storageService.retrieveAllSubscriptions()) {
            Log.debug("Re-subscribing {} to topic {}", subscription.getClientId(), subscription.getTopic());
            addDirect(subscription);
        }
        if (Log.DEBUG) {
            Log.debug("Finished loading. Subscription tree after {}", dumpTree());
        }
    }
478466
private function setKeyValueStorage($storage)
    {
        if (!is_object($storage)) {
            throw new InvalidArgumentException("An instance of valid storage must be provided");
        }

        $storageClasses = class_implements($storage);
        $validStorages = ['Cloudinary\Cache\Storage\KeyValueStorage', 'Psr\SimpleCache\CacheInterface'];

        $found = count(\Cloudinary::array_subset($storageClasses, $validStorages)) > 0;

        if (!$found) {
            throw new InvalidArgumentException("An instance of valid storage must be provided");
        }

        $this->keyValueStorage = $storage;

        return true;
    }
703847
public function storage(StorageInterface $storage = null)
    {
        if ($storage !== null) {
            $this->_storage = $storage;

            return null;
        }

        if ($this->_storage) {
            return $this->_storage;
        }

        $config = $this->_config['storage'];
        if (is_string($config)) {
            $class = $config;
            $config = [];
        } else {
            $class = $config['className'];
            unset($config['className']);
        }
        $className = App::className($class, 'Auth/Storage', 'Storage');
        if (!class_exists($className)) {
            throw new Exception(sprintf('Auth storage adapter "%s" was not found.', $class));
        }
        $request = $this->getController()->getRequest();
        $response = $this->getController()->getResponse();
        $this->_storage = new $className($request, $response, $config);

        return $this->_storage;
    }