Get the response from the file if available.

@param array $tags

@return array|null
351174
protected function getFileResponses(array $tags)
    {
        // avoid "holes" in the keys of the filtered array, by using array_values on the filtered array
        $responseFileTags = array_values(
            array_filter($tags, function ($tag) {
                return $tag instanceof Tag && strtolower($tag->getName()) === 'responsefile';
            })
        );

        if (empty($responseFileTags)) {
            return;
        }

        return array_map(function (Tag $responseFileTag) {
            preg_match('/^(\d{3})?\s?([\S]*[\s]*?)(\{.*\})?$/', $responseFileTag->getContent(), $result);
            $status = $result[1] ?: 200;
            $content = $result[2] ? file_get_contents(storage_path(trim($result[2])), true) : '{}';
            $json = ! empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}';
            $merged = array_merge(json_decode($content, true), json_decode($json, true));

            return new JsonResponse($merged, (int) $status);
        }, $responseFileTags);
    }
316714
protected function getFilePayload(?array $files) : ?array
    {
        if (empty($files)) {
            return null;
        }

        $files = array_filter($files, function($file) {
            return $file instanceof ResourceSettings || (isset($file['key']) && isset($file['filename']));
        });

        return $files;
    }
681518
public function getEvents(array $tags = []): array
    {
        if ($tags === []) {
            return $this->events;
        }

        return array_filter($this->events, function (ScheduleEvent $event) use ($tags) {
            return array_intersect($event->getTags(), $tags) === $tags;
        });
    }
1048896
public static function makeTagsArray($tags)
    {
        if (is_array($tags)) {
            $tags = array_unique(array_filter($tags));
        } else if (is_string($tags)) {
            $tags = preg_split('#[' . preg_quote(',', '#' ) . ']#', $tags, null, PREG_SPLIT_NO_EMPTY);
        } else {
            $tags = $tags->toArray();
        }

        $tagSet = [];
        foreach ($tags as $tag)
            $tagSet[] = Tag::taggify($tag);

        return $tagSet;
    }
1056103
public function getTag($tag)
    {
        return isset($this->tags[$tag]) ? $this->tags[$tag] : null;
    }
1328711
public function getEntry($tag)
    {
        if (isset($this->entries[$tag])) {
            return $this->entries[$tag];
        } else {
            return null;
        }
    }
1240728
private function preProcessTags($tags): array
    {
        if (!$tags) {
            return $this->getRegistered();
        }

        if (is_string($tags)) {
            $tags = explode('|', $tags);
        }

        return array_filter($tags, [$this, 'isRegistered']);
    }
180652
public function getCmd($tag)
    {
        return isset($this->_commands[$tag])
            ? $this->_commands[$tag]
            : null;
    }
121567
public function getTagged($tag)
	{
		$services = array();

		if (isset($this->tags[$tag]))
		{
			foreach ($this->tags[$tag] as $service)
			{
				$services[] = $this->get($service);
			}
		}

		return $services;
	}
1059730
public static function serializeTags(array $tags)
    {
        if (empty($tags))
            return '';

        self::validateTags($tags);
        $tagstrs = array();
        foreach ($tags as $tag)
            $tagstrs[] = $tag->toString(true);

        return implode(';', $tagstrs);
    }
174391
private static function parseFetchTdTable($fields, $tag = 'td')
    {

        $td_fetch = null;
        foreach ($fields as $h) {

            $attrs = array();
            $value = null;

            if (is_array($h)) {
                $attrs   = isset($h["@attrs"]) ? $h["@attrs"] : array();
                $value   = isset($h['value']) ? $h['value'] : null;

            }
            else {
                $value = $h;
            }

            $td_fetch .= self::tag($tag, $value, null, null, $attrs);
        }

        return $td_fetch;

    }
1040717
public function findAdminChildrenFromTags(array $tags)
    {
        if (count($tags) === 0) {
            throw new \InvalidArgumentException('Array argument cannot be empty');
        }

        $index = 0;
        $eol = PHP_EOL;
        $tagsTest = '(';

        foreach ($tags as $tag) {
            $tagsTest .= $index > 0 ? '    OR ' : '    ';
            $tagsTest .= "p.id = {$tag}{$eol}";
            $index++;
        }
        $tagsTest .= "){$eol}";

        $dql = "
            SELECT DISTINCT t
            FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTag t
            WHERE t.user IS NULL
            AND EXISTS (
                SELECT h
                FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h
                JOIN h.parent p
                WHERE h.user IS NULL
                AND h.tag = t
                AND {$tagsTest}
            )
            ORDER BY t.name
        ";
        $query = $this->_em->createQuery($dql);

        return $query->getResult();
    }
214282
private function _parseTags($tags)
        {
            if(count($tags) > 0)
            {   
//              loop through the tags
                foreach($tags as $key=>$tag)
                {   
//                  if a tag is delayed, it is rendered after everything else and it's has to be re parsed.
                    if(isset($tag['attributes']) === true && isset($tag['attributes']->delayed) === true && $tag['attributes']->delayed === 'true')
                    {
                        continue;
                    }
//                  check for buried preserved tags, so they can be replaced.
//                  NOTE: this only works with no collected tags. Collected tags are a massive pain in the rectum.
                    if(($has_buried = preg_match_all('!------@@%([0-9\-]+)%@@------!', $tag['content'], $info)) > 0)
                    {   
                        $containers = $info[0];
                        $indexs = $info[1];
                        $replacements = array();
                        foreach ($indexs as $key2=>$index)
                        {
                            $index_parts = explode('-', $index);
                            $tag_index = array_pop($index_parts);
                            if(isset($tags[$tag_index]['parsed']) === true)
                            {
                                $replacements[$key2] = $tags[$tag_index]['parsed'];
                            }
                            else
                            {   
                                if(isset($tags[$tag_index]['block']) === true)
                                {
                                    $block = preg_replace('/ delayed="true"/', '', $tags[$tag_index]['block'], 1);
                                    if(isset($tag['block']) === true)
                                    {
                                        $tag['block'] = str_replace($containers[$key2], $block, $tag['block']); 
                                    }
                                    $tag['content'] = str_replace($containers[$key2], $block, $tag['content']); 
                                }
                            }
                        }
                        $tags[$key]['buried_source_markers'] = $tag['buried_source_markers'] = $containers;
                    }

//                  if the tag is a nocahe tag then the block must be replaced as is for later processing
                    if($tag['name'] === 'nocache')
                    {
                        array_push(self::$nocache_tags, $tag);
                        $tags[$key]['parsed'] = $tag['source_marker'];
//                      $tags[$key]['parsed'] = $tag['block'];
                    }
//                  if the tag is just plain text then just shove the content back into the parsed as it doesn't require processing
                    else if($tag['name'] === '___text')
                    {
                        $tags[$key]['parsed'] = $tag['content'];
                    }
//                  otherwise we have a tag and must post process
                    else
                    {   
                        $tags[$key]['parsed'] = $this->_parseTag($tag);
                    }
//                  update any buried tags within the parsed content
                    $tags[$key]['parsed'] = $has_buried > 0 ? str_replace($containers, $replacements, $tags[$key]['parsed']) : $tags[$key]['parsed'];
                }
// //              if there are items within the nocache elements, parse the contents to pull them out
//                 $tagname = $this->_options['tag_name'];
//                 if(substr_count($tags[$key]['parsed'], self::$tag_open.$tagname.':') > substr_count($tags[$key]['parsed'], self::$tag_open.$tagname.':nocache'))
//                 {
//                     $tags[$key]['parsed'] = $this->parse($tags[$key]['parsed'], true, true);
// //                  $tags[$key]['parsed'] = $this->_processTags($tags[$key]['parsed'], true);
//                 }
                
//                 Debug::info($tags[$key]);
                
                return $tags[$key]['parsed'];
            }
            return false;
        }
475303
protected function getFormattedTags(array $tags)
    {
        $add =array();

        foreach ($tags as $key => $value) {
            if (is_bool($value)) {
                $value = $value ? "true" : "false";
            }
            $add[] = "#$key:$value";
        }

        return !empty($add) ? '|'.implode(',', $add) : null;
    }
960822
protected function behatTagsFactory(array $tags)
    {
        $fileTokens = [];

        $files = Finder::create()->files()->in($this->plugin->directory)->path('tests/behat')->name('*.feature')->getIterator();
        foreach ($files as $file) {
            $fileTokens[] = FileTokens::create($file->getRelativePathname())->mustHaveAll($tags);
        }

        return $fileTokens;
    }
1241694
private function loadTagContent(): ?string
    {
        $contents = [];
        $nextOrClosingPos = $this->file->findNext([T_DOC_COMMENT_CLOSE_TAG, T_DOC_COMMENT_TAG], $this->stackPos + 1);
        $positionsTillEnd = TokenHelper::findNextAll($this->file->getBaseFile(), [T_DOC_COMMENT_STRING], $this->stackPos, $nextOrClosingPos);

        foreach ($positionsTillEnd as $position) {
            $contents[] = $this->tokens[$position]['content'];
        }

        return $contents ? implode(' ', $contents) : null;
    }
956533
public function findByTags(array $tags)
    {
        $qb = $this->createQueryBuilder('c');

        foreach ($tags as $key => $tag) {
            $operator = substr($tag, 0, 1);

            if ($operator === '+' || $operator === '-') {
                $tag = substr($tag, 1);
            }

            $literalExpr = $qb->expr()->literal('%'.$tag.'%');

            if ($operator === '-') {
                $qb->andWhere($qb->expr()->notLike('c.tags', $literalExpr));
            } elseif ($operator === '+') {
                $qb->andWhere($qb->expr()->like('c.tags', $literalExpr));
            } elseif ($key === 0) {
                $qb->where($qb->expr()->like('c.tags', $literalExpr));
            } else {
                $qb->orWhere($qb->expr()->like('c.tags', $literalExpr));
            }
        }

        return $qb->getQuery()->getResult();
    }