Process contents of a section

@param  array $contents Section contents
@return array
3506
private function processSectionContents(array $contents)
    {
        $result = [];

        // loop through each line and convert it to an array
        foreach ($contents as $path => $value) {
            // convert all a.b.c.d to multi-dimensional arrays
            $process = $this->processContentEntry($path, $value);
            // merge the current line with all previous ones
            $result = $this->arrayMergeRecursiveDistinct($result, $process);
        }

        return $result;
    }
1343176
private function recursivelyArrayify($content = null)
        {
            $return = [];
            if (false === $content || null === $content) {
                return;
            } else if ($content instanceof Element) {
                $return[] = $content->toArray();
            } else if (!is_array($content)) {
                $return[] = $content;
            } else {
                foreach ($content as $element) {
                    $return[] = $this->recursivelyArrayify($element);
                }
            }
            return $return;
        }
263759
protected function processParts(array $parts)
    {
        return array_values(array_filter($parts, function ($part) {
            if (empty($part) || $part instanceof CommentPart) {
                return false;
            }
            return true;
        }));
    }
806561
public function addContents($contents)
    {
        if (current($contents) instanceof Content) {
            foreach ($contents as $content) {
                $this->addContent($content);
            }
        } else {
            foreach ($contents as $key => $value) {
                $this->addContent($key, $value);
            }
        }
    }
1002130
public function process(array $items)
    {
        foreach ($items as $key => $item) {
            $items[$key] = $this->doClean($item);
        }

        return $items;
    }
1319376
public function replaceIdxContentContents(array $contents)
    {
        $parentUids = array();
        foreach ($contents as $content) {
            // avoid loop if content is already treated
            if (null === $content || true === $content->isElementContent()) {
                continue;
            } elseif (true === array_key_exists($content->getUid(), $parentUids)) {
                break;
            } elseif (false === array_key_exists($content->getUid(), $parentUids)) {
                $parentUids[$content->getUid()] = array($content->getUid());
            }

            $parentUids[$content->getUid()] = array_merge($parentUids[$content->getUid()], $this->getAClassContentUids($content->getSubcontent()->toArray()));
        }

        return $this->replaceIdxContentContentsByUids($parentUids);
    }
1018881
public function process(array $values)
    {
        $results = [];

        foreach ($values as $value) {
            $results = array_merge($results,
                $this->getSolrRootlineForCategoryId($value));
        }

        return $results;
    }
1314315
public function parseArray(array $ini)
    {
        $sections = [];

        foreach ($ini as $name => $section) {
            $section = $this->parseSection($name, $section);
            $sections[] = $section;
        }

        return $sections;
    }
896202
public function compactContents($file, $contents)
    {
        foreach ($this->compactors as $compactor) {
            /** @var $compactor CompactorInterface */
            if ($compactor->supports($file)) {
                $contents = $compactor->compact($contents);
            }
        }

        return $contents;
    }
1336230
private static function processContentEntry($path, $value)
    {
        $pos = strpos($path, '.');
        
        if ($pos === false) {
            return array(
                $path => $value
            );
        }
        
        $key = substr($path, 0, $pos);
        $path = substr($path, $pos + 1);
        
        $result = array(
            $key => self::processContentEntry($path, $value)
        );
        
        return $result;
    }
1303274
protected function parse(array $sections = [])
    {
        if (isset($sections['subject']) && ! is_null($sections['subject'])) {
            $this->subject = $sections['subject'];
        }

        if (isset($sections['view']) && ! is_null($sections['view'])) {
            $this->view = $sections['view'];
        }
    }
873580
public function prepareContent($content)
    {
        if (is_array($content)) {
            $ctt = '';
            foreach ($content as $key=>$ctt_entry) {
                $ctt .= $ctt_entry;
            }
            $content = $ctt;
        }
        return (string) $content;
    }
1361167
protected function decodeContent(string $content): array
    {
        $result = json_decode($content, true);
        return is_array($result) ? $result : [];
    }
1237044
protected function set_data(array $contents = [])
    {
        foreach ($contents as $key => $file) {
            $this->data[ $key ] = $this->add_file($file);
        }
    }
1127124
protected function process_toc() {
        if (empty($this->toc)) {
            return;
        }

        $toc = "";
        $currentsection = array(0, 0, 0);
        $i = 1;
        foreach ($this->toc as & $header) {
            switch ($header[0]) {
            case 1:
                $currentsection = array($currentsection[0] + 1, 0, 0);
                break;
            case 2:
                $currentsection[1]++;
                $currentsection[2] = 0;
                if ($currentsection[0] == 0) {
                    $currentsection[0]++;
                }
                break;
            case 3:
                $currentsection[2]++;
                if ($currentsection[1] == 0) {
                    $currentsection[1]++;
                }
                if ($currentsection[0] == 0) {
                    $currentsection[0]++;
                }
                break;
            default:
                continue 2;
            }
            $number = "$currentsection[0]";
            if (!empty($currentsection[1])) {
                $number .= ".$currentsection[1]";
                if (!empty($currentsection[2])) {
                    $number .= ".$currentsection[2]";
                }
            }
            $toc .= parser_utils::h('p', $number . ". " .
               parser_utils::h('a', str_replace(array('[[', ']]'), '', $header[1]), array('href' => "#toc-$i")),
               array('class' => 'wiki-toc-section-' . $header[0] . " wiki-toc-section"));
            $i++;
        }

        $this->returnvalues['toc'] = "<div class=\"wiki-toc\"><p class=\"wiki-toc-title\">" . get_string('tableofcontents', 'wiki') . "</p>$toc</div>";
    }
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();
    }
829731
public function getContents()
    {
        if ($this->contents) {
            if ($this->contents[0]->getType() !== 'text/plain'
            && count($this->contents) > 1
            ) {
                foreach ($this->contents as $key => $value) {
                    if ($value->getType() == 'text/plain') {
                        $plain_content = $value;
                        unset($this->contents[$key]);
                        break;
                    }
                }
                array_unshift($this->contents, $plain_content);
            }
        }

        return $this->contents;
    }