Process the directory of JSON files using the collected pattern ids

@param string[] $coveredIds
100
public function process(array $coveredIds) : void
    {
        $this->setCoveredPatternIds($coveredIds);

        $finder = new Finder();
        $finder->files();
        $finder->name('*.json');
        $finder->ignoreDotFiles(true);
        $finder->ignoreVCS(true);
        $finder->sortByName();
        $finder->ignoreUnreadableDirs();
        $finder->in($this->resourceDir);

        foreach ($finder as $file) {
            /* @var \Symfony\Component\Finder\SplFileInfo $file */

            /** @var string $patternFileName */
            $patternFileName = mb_substr($file->getPathname(), (int) mb_strpos($file->getPathname(), 'resources/'));

            if (!isset($this->coveredIds[$patternFileName])) {
                $this->coveredIds[$patternFileName] = [];
            }

            $this->coverage[$patternFileName] = $this->processFile(
                $patternFileName,
                $file->getContents(),
                $this->coveredIds[$patternFileName]
            );
        }
    }
516624
protected function _clearCache( array $ids )
	{
		$domain = str_replace( '_', '/', strtolower( $this->_name ) );
		$tags = array( $domain );

		foreach( $ids as $id ) {
			$tags[] = $domain . '-' . $id;
		}

		$this->_context->getCache()->deleteByTags( $tags );
	}
624283
public function scanJsonFiles()
    {
        $themes = [];
        foreach (glob($this->themes_path('*'), GLOB_ONLYDIR) as $themeFolder) {
            $themeFolder = realpath($themeFolder);
            if (file_exists($jsonFilename = $themeFolder . '/' . 'theme.json')) {

                $folders = explode(DIRECTORY_SEPARATOR, $themeFolder);
                $themeName = end($folders);

                // default theme settings
                $defaults = [
                    'name'       => $themeName,
                    'asset-path' => $themeName,
                    'extends'    => null,
                ];

                // If theme.json is not an empty file parse json values
                $json = file_get_contents($jsonFilename);
                if ($json !== "") {
                    $data = json_decode($json, true);
                    if ($data === null) {
                        throw new \Exception("Invalid theme.json file at [$themeFolder]");
                    }
                } else {
                    $data = [];
                }

                // We already know views-path since we have scaned folders.
                // we will overide this setting if exists
                $data['views-path'] = $themeName;

                $themes[] = array_merge($defaults, $data);
            }
        }
        return $themes;
    }
730744
def process_ids ids
      case ids
      when Range
        return id_range_to_s(ids)
      when Array
        return id_a_to_s(ids)
      when String
        return ids.delete(" ")
      when Fixnum
        return ids
      end
    end
1039484
function levelsToSelect($levelIds, $mode)
    {
        $levelsToSelect = array();
        foreach ($this->schema->getLevels() as $level) {
            if (self::INCLUDE_PARTIALS == $mode && !$levelIds[$level]) {
                continue;
            }
            if (self::INCLUDE_PARTIALS == $mode && !$levelIds[$level]) {
                continue;
            }
            array_push($levelsToSelect, $level);
        }
        return $levelsToSelect;
    }
75344
public function move($fileIDs, $parentID)
    {
        if (is_array($fileIDs)) {
            $fileIDs = implode(',', $fileIDs);
        }

        $data = [
            'file_ids'  => $fileIDs,
            'parent_id' => $parentID
        ];

        return $this->post('files/move', $data, \true);
    }
700672
public function cleanup( array $siteids )
	{
		$context = $this->_getContext();
		$config = $context->getConfig();
		$search = $this->createSearch();

		$path = 'classes/catalog/manager/submanagers';
		foreach( $config->get( $path, array( 'list' ) ) as $domain ) {
			$this->getSubManager( $domain )->cleanup( $siteids );
		}

		$dbm = $context->getDatabaseManager();
		$dbname = $this->_getResourceName();
		$conn = $dbm->acquire( $dbname );

		try
		{
			$path = 'mshop/catalog/manager/default/item/delete';
			$sql = $config->get( $path, $path );

			$types = array( 'siteid' => MW_DB_Statement_Abstract::PARAM_STR );
			$translations = array( 'siteid' => '"siteid"' );

			$search->setConditions( $search->compare( '==', 'siteid', $siteids ) );
			$sql = str_replace( ':siteid', $search->getConditionString( $types, $translations ), $sql );

			$stmt = $conn->create( $sql );
			$stmt->bind( 1, 0, MW_DB_Statement_Abstract::PARAM_INT );
			$stmt->bind( 2, 0x7FFFFFFF, MW_DB_Statement_Abstract::PARAM_INT );
			$stmt->execute()->finish();

			$dbm->release( $conn, $dbname );
		}
		catch( Exception $e )
		{
			$dbm->release( $conn, $dbname );
			throw $e;
		}
	}
1327266
protected function deleteMatchingFiles($wildcard, $ignored = null)
    {
        if (is_array($files = $this->files->glob($wildcard)))
        {
            foreach ($files as $path)
            {
                if ( ! is_null($ignored))
                {
                    // Spin through each of the ignored assets and if the current file path ends
                    // with any of the ignored asset paths then we'll skip this asset as it
                    // needs to be kept.
                    foreach ((array) $ignored as $ignore)
                    {
                        if (ends_with($path, $ignore)) continue 2;
                    }
                }

                $this->files->delete($path);
            }
        }
        
    }
56623
protected function processJsonld(array $jsonld, $drupal_url, $fedora_url)
    {
        // Strip out everything other than the resource in question.
        $resource = array_filter(
            $jsonld['@graph'],
            function (array $elem) use ($drupal_url) {
                return $elem['@id'] == $drupal_url;
            }
        );

        // Put in an fedora url for the resource.
        $resource[0]['@id'] = $fedora_url;

        return $resource;
    }
327496
private function getCoverageCount(string $id, array $covered) : int
    {
        $id              = str_replace('\/', '/', $id);
        [$u, $c, $d, $p] = explode('::', $id);

        $u = preg_quote(mb_substr($u, 1), '/');
        $c = preg_quote(mb_substr($c, 1), '/');
        $p = preg_quote(mb_substr($p, 1), '/');
        $d = preg_quote(mb_substr($d, 1), '/');

        $count = 0;

        if (0 === mb_strlen($p)) {
            $p = '.*?';
        }
        if (0 === mb_strlen($d)) {
            $d = '.*?';
        }

        $regex = sprintf('/^u%d::c%d::d%s::p%s$/', $u, $c, $d, $p);

        foreach ($covered as $patternId) {
            if (preg_match($regex, $patternId)) {
                ++$count;
            }
        }

        return $count;
    }
638247
protected function _processTree($file, $nodes, $coverage, $path = '')
    {
        foreach ($nodes as $node) {
            $this->_processNode($file, $node, $coverage, $path);
        }
    }
215786
public function findDocuments(array $ids, $limit = null, $offset = null)
    {
        $path = "/{$this->name}/_all_docs?include_docs=true";

        if (null !== $limit) {
            $path .= '&limit='.(integer) $limit;
        }
        if (null !== $offset) {
            $path .= '&skip='.(integer) $offset;
        }

        $response = $this->client->request('POST', $path, [
            'body'    => JSONEncoder::encode(['keys' => $ids]),
            'headers' => ['Content-Type'             => 'application/json'],
        ]);

        return JSONEncoder::decode((string) $response->getBody());
    }
27210
private function mergeGenerated($generated)
    {
        if (! is_array($generated)) {
            $this->generatedFiles[$generated->getUid()] = $generated;
        } else {
            foreach ($generated as $file) {
                $this->mergeGenerated($file);
            }
        }
    }
1042979
private function serializeIncludedObjectsWithCacheKey($includeObjects, $linkedIds, $serializedData)
    {
        foreach ($includeObjects as $object) {
            $includeType = $object['type'];
            $includeId = $object['id'];
            $cacheKey = "$includeType:$includeId";
            if (!array_key_exists($cacheKey, $linkedIds)) {
                $serializedData[] = $object;
                $linkedIds[$cacheKey] = $object;
            }
        }
        return [$serializedData, $linkedIds];
    }
1324850
protected function createAggregationQueryBuilderWithSiteIds(array $siteIds)
    {
        $qa = $this->createAggregationQuery();
        foreach ($siteIds as $key => $siteId) {
            $siteIds[$key] = new \MongoId($siteId);
        }
        $qa->match(
            array('site.$id' => array('$in' => $siteIds)),
            array('deleted' => false)
        );

        return $qa;
    }
229205
public function setHashIds($hashIdsConfig = [])
    {
        $defaultConfig = DataRepository::getData('hashids_config');
        if (isset($hashIdsConfig['salt'])) {
            $this->hashIds['salt'] = $hashIdsConfig['salt'];
        } else {
            $this->hashIds['salt'] = $defaultConfig['salt'];
        }
        if (isset($hashIdsConfig['minHashLength'])) {
            $this->hashIds['minHashLength'] = $hashIdsConfig['minHashLength'];
        } else {
            $this->hashIds['minHashLength'] = $defaultConfig['minHashLength'];
        }
        if (isset($hashIdsConfig['alphabet'])) {
            $this->hashIds['alphabet'] = $hashIdsConfig['alphabet'];
        } else {
            $this->hashIds['alphabet'] = $defaultConfig['alphabet'];
        }
    }
763629
private String _serializeArray(Array array, Map<Object, String> done, String id) throws ConverterException {
	return _serializeList(array.toList(), done, id);
    }