Function generates block filter path

@param array $contents Array with contents

@return string
484629
private function getRandomBlockFilter($contents)
    {
        return rand(0, 1) ? $contents[array_rand($contents)]->path . '*' : $contents[array_rand($contents)]->path;
    }
543660
public function getHeaders(string $content): array
    {
        \preg_match_all('/(?<=["\'])[^="\']*\.css(\.gzi?p?)?(\?\d*)?(?=["\'])/', $content, $cssFiles);
        $paths = $this->streamlineFilePaths((array)$cssFiles[0]);

        return $this->mapPathsWithType($paths, 'style');
    }
820346
public function getDescendantsContentUids($contents)
    {
        if (false === is_array($contents)) {
            $contents = array($contents);
        }

        $meta = $this->_em->getClassMetadata('BackBee\ClassContent\Indexes\IdxContentContent');

        $q = $this->_em->getConnection()
                ->createQueryBuilder()
                ->select('c.'.$meta->getColumnName('subcontent_uid'))
                ->from($meta->getTableName(), 'c');

        $index = 0;
        $atleastone = false;
        foreach ($contents as $content) {
            if (false === ($content instanceof AbstractClassContent)) {
                continue;
            }

            if (true === $content->isElementContent()) {
                continue;
            }

            $q->orWhere('c.'.$meta->getColumnName('content_uid').' = :uid'.$index)
                    ->setParameter('uid'.$index, $content->getUid());

            $index++;
            $atleastone = true;
        }

        return (true === $atleastone) ? array_unique($q->execute()->fetchAll(\PDO::FETCH_COLUMN)) : array();
    }
510338
protected function multipartFinalize(Array $multiparts = []) {
    $contents = '';
    foreach ($multiparts as $multipart) {
      $contents .= $multipart;
    }
    $contents .= '--' . $this->boundary  . '--';
    $contents .= static::EOL;
    return $contents;
  }
1027581
protected function rewriteImagesPathForProduction($content)
    {
        $imagesSourcePath = $this->imagesSourcePath;
        $imagesTargetPath = $this->imagesTargetPath;

        return preg_replace_callback('/([\/]?)(' . str_replace('/', '\/', $imagesSourcePath) . ')/s', function ($matches) use ($imagesTargetPath) {return $matches[1].$imagesTargetPath;}, $content);
    }
1267706
public function acfLoadClean($paths)
    {
        $paths = array_unique($paths);

        foreach ($paths as $path) {
            foreach (@glob($path . '/*.json') as $file) {
                $json = json_decode(file_get_contents($file));

                if (!is_array($json)) {
                    continue;
                }

                $content = file($file);

                if (trim($content[0]) == '[') {
                    array_shift($content);
                    array_pop($content);
                }

                file_put_contents($file, $content);
            }
        }

        return $paths;
    }
873580
public function prepareContent($content)
    {
        if (is_array($content)) {
            $ctt = '';
            foreach ($content as $key=>$ctt_entry) {
                $ctt .= $ctt_entry;
            }
            $content = $ctt;
        }
        return (string) $content;
    }
504826
private function generateNavigation(
        $contents,
        $webspace,
        $language,
        $flat = false,
        $context = null,
        $breakOnNotInNavigation = false,
        $recursive = true
    ) {
        $result = [];

        /** @var StructureInterface $content */
        foreach ($contents as $content) {
            if ($this->inNavigation($content, $context)) {
                $url = $content->getResourceLocator();
                $title = $content->getNodeName();
                $children = $recursive ? $this->generateChildNavigation($content, $webspace, $language, $flat, $context) : [];

                if (false === $flat) {
                    $result[] = new NavigationItem(
                        $title,
                        $url,
                        isset($content->getExt()['excerpt']) ? $content->getExt()['excerpt'] : null,
                        $children,
                        $content->getUuid(),
                        $content->getNodeType()
                    );
                } else {
                    $result[] = new NavigationItem(
                        $title,
                        $url,
                        isset($content->getExt()['excerpt']) ? $content->getExt()['excerpt'] : null,
                        null,
                        $content->getUuid(),
                        $content->getNodeType()
                    );
                    $result = array_merge($result, $children);
                }
            } elseif (true === $flat) {
                $children = $recursive ? $this->generateChildNavigation($content, $webspace, $language, $flat, $context) : [];
                $result = array_merge($result, $children);
            } elseif ($breakOnNotInNavigation) {
                break;
            }
        }

        return $result;
    }
1245193
private function joinPath(...$paths)
    {
        $resultPath = null;

        foreach($paths as $path) {
            if ($resultPath === null || (!empty($path) && $path[0] === '/')) {
                $resultPath = $path;
            } else {
                $resultPath = $resultPath . '/' . $path;
            }
        }

        $resultPath = preg_replace('~/{2,}~','/', $resultPath);

        if ($resultPath === '/') {
            return '/';
        }

        $resultPathParts = [];
        foreach(explode('/',rtrim($resultPath,'/')) as $part) {
            if ('.' === $part) {
                continue;
            }

            if ('..' === $part && count($resultPathParts) > 0) {
                array_pop($resultPathParts);
                continue;
            }

            $resultPathParts[] = $part;
        }

        return implode('/',$resultPathParts);
    }
593383
public function generateViewFile($content)
    {
        $name = $this->getRandomName();

        $path = sys_get_temp_dir();

        $filename = $path.'/'.$name.'.twig';

        if (!file_exists(dirname($filename))) {
            mkdir(dirname($filename), 0755, true);
        }

        file_put_contents($filename, $content);

        return $filename;
    }
1360382
protected function applySiteSpecificFilters($content)
    {
        $filters = $this->getSiteSpecificFilters();

        $from = array_keys($filters);
        $to = array_values($filters);

        return str_replace($from, $to, $content);
    }
334010
protected function _replace($content)
    {
        $content = trim($content, "\r\n ");
        if (!$this->blocks) {
            return $content;
        }

        return strtr($content, $this->blocks);
    }
298666
protected function filterContentsByType($contents, $type)
	{
		return Collection::make($contents)
			->where('type', $type)
			->fetch('path')
			->values()->all();
	}
702172
private function _filterPath($path)
    {
        $path = preg_replace_callback(
            '/(?:[^' . self::UNRESERVED_CHARACTERS . self::SUB_DELIMS_CHARACTERS . '%:@\/]+|%(?![A-Fa-f0-9]{2}))/',
            [$this, '_rawUrlEncode'],
            $path
        );

        if ($path && $path[0] === '/') {
            $path = '/' . ltrim($path, '/');
        }

        return $path;
    }
434751
protected function addQueueConfig($contents)
    {
        if (str_contains($contents, "'gae'")) {
            return $contents;
        }

        $expression = "/'connections'\s*=>\s*\[/";

        $replacement =
<<<EOT
'connections' => [

        'gae' => [
            'driver'	=> 'gae',
            'queue'		=> 'default',
            'url'		=> '/tasks',
            'encrypt'	=> true,
        ],
EOT;
        $modified = preg_replace($expression, $replacement, $contents);

        if ($contents !== $modified) {
            $this->myCommand->info('Added queue driver configuration in "config/queue.php".');
        }

        return $modified;
    }
909922
public function generateSearchText($content)
    {
        $content = $this->_defaultData($content);
        $content['link'] = str_replace('internal://', '', $content['link'], $count);
        if ($count > 0) {
            $paths = Path::getById($content['link']);
            $content['link'] = $paths->exists ? $paths->name : '';
        }
        return parent::generateSearchText($content['link']);
    }
403213
protected function findBlocksForPath($routable, $filter)
    {
        if (is_string($routable)) { // static page like "home", "contact" etc.
            return $this->handleStaticPageCase($routable, $filter);
        }
        $ids      = $routable->getTreePath();
        $idsCount = count($ids);
        $blockIds = [];
        if ($idsCount === 1) { // Root case
            $allIds   = [];
            $rootPath = $ids[0] . '/';
            if (isset($filter['paths'][$rootPath])) {
                $allIds = $filter['paths'][$rootPath];
            }
            // We're returning only blocks ids that uses filter property
            $blockIds = array_keys($allIds + $filter['excluded'], true, true);
        } else {
            $allIds     = [];
            $parentPath = '';
            foreach ($ids as $index => $id) {
                $parentPath .= $id . '/';
                $pathMatch  = ($index + 1 < $idsCount) ? $parentPath . '*' : $parentPath;
                if (isset($filter['paths'][$pathMatch])) {
                    // Order of operation is important! We want to override $allIds be lower level filter (left overrides right)
                    $allIds = $filter['paths'][$pathMatch] + $allIds;
                }
            }
            // We're returning only blocks ids that uses filter property
            $blockIds = array_keys($allIds + $filter['excluded'], true, true);
        }
        return $blockIds;
    }