@param ContentInterface $content
@param array            $args

@return string
341503
public function toHTML(ContentInterface $content, array $args)
    {
        if (isset($args['output'])) {
            return $args['output'];
        }

        $tags = array_merge($args, $content->getMetaTagArray());
        if (!isset($tags['pre'])) {
            $pre = "\n       ";
        } else {
            $pre = $tags['pre'];
            unset($tags['pre']);
        }

        return self::createMetaTags($pre, $tags, $this->filter);
    }
1038137
public function renderOpenGraphTags(Content $content)
    {
        try {
            return $this->tagRenderer->render(
                $this->getOpenGraphTags($content)
            );
        } catch (Exception $e) {
            if ($this->throwExceptions || !$this->logger instanceof LoggerInterface) {
                throw $e;
            }

            $this->logger->error($e->getMessage());
        }

        return '';
    }
214149
public function getFieldGroupValuesForContent(ContentInterface $content = null, $slug)
    {
        if (null === $content) {
            return [];
        }

        foreach ($content->getFieldValues() as $fieldValue) {
            if ($fieldValue->getField()->getSlug() == $slug) {
                return $fieldValue->getChildren();
            }
        }
        return [];
    }
197713
public function duplicate(ContentInterface $content)
    {
        //get valueset to clone
        $valueset = $content->getValueSet();

        //clone valueset
        $duplicatedValueset = clone $valueset;

        $this->detachAndPersist($duplicatedValueset);

        //duplicate content
        $duplicatedContent = clone $content;
        $duplicatedContent->setSlug(null);
        $duplicatedContent->setValueSet($duplicatedValueset);

        $this->detachAndPersist($duplicatedContent);

        //iterate values, clone each and assign duplicate valueset to it
        foreach ($valueset->getValues() as $value) {

            //skip empty attributes
            if (is_null($value->getId())) continue;

            $duplicatedValue = clone ($value);
            $duplicatedValue->setValueSet($duplicatedValueset);

            $this->detachAndPersist($duplicatedValue);
        }
        $this->em->flush();

        return $duplicatedContent->getId();
    }
1151682
public static function expandParameterArrays($content, array $parameters)
    {
        return preg_replace_callback('/\?/', function () use (& $parameters) {
            $parameter = current(each($parameters));
            return is_array($parameter) ? Compiler::toPlaceholders($parameter) : '?';
        }, $content);

    }
342980
public function buildContent(Model\ContentInterface $content)
    {
        $view = new ContentView();
        $attributes = $view->getAttributes()->addClass('cms-content');

        if ($this->editor->isEnabled()) {
            $attributes
                ->setId('cms-content-' . $content->getId())
                ->setData([
                    'id'      => $content->getId(),
                    'actions' => [
                        // TODO
                    ],
                ]);
        }

        // Layout
        $this->editor->getLayoutAdapter()->buildContent($content, $view);

        foreach ($content->getContainers() as $container) {
            $view->containers[] = $this->buildContainer($container);
        }

        return $view;
    }
61617
protected function encodeContent(array $args) {
        $data = [];
        foreach ($args as $key => $item) {
            $data[] = sprintf('"%s":"%s"', $key, $item);
        }
        $arg = '{'.implode(',', $data).'}';
        if (!empty($this->encryptKey)
            && $this->encryptType == self::AES) {
            return (new Aes($this->encryptKey))->encrypt($arg);
        }
        return $arg;
    }
1337545
protected function _doTable(&$content, array &$args = array())
    {
        $table = new TableTool(
            isset($content['body']) && is_array($content['body']) ? $content['body'] : array($content),
            isset($content['head']) && is_array($content['head']) ? $content['head'] : array(),
            isset($content['foot']) && is_array($content['foot']) ? $content['foot'] : array()
        );
        $table_stacks = $table->getTable();

        // each line building
        $table_content = '';
        foreach(self::$table_scopes as $scope) {
            $scope_lines = '';
            if (isset($table_stacks[$scope]) && is_array($table_stacks[$scope]) && !empty($table_stacks[$scope])) {
                $my_line = '';
                foreach($table_stacks[$scope] as $line) {
                    $this->_doTableLine($line, $args, $scope);
                    $my_line .= $line;
                }
                $scope_lines .= $my_line;
            }
            $scope_args = $this->_getArgsStack($args, $scope);
            $scope_tag = 'table_'.$scope;
            $table_content .= $this->_tagComposer($scope_lines, $scope_tag, $scope_args);
        }

        // caption
        if (isset($table_stacks['title'])) {
            $caption_args = $this->_getArgsStack($args, 'title');
            $caption_tag = 'table_title';
            $caption = $this->_tagComposer($table_stacks['title'], $caption_tag, $caption_args);
            $table_content = $caption.$table_content;
        }

        $this->_purgeArgsStackForTable($args, 'cell');
        $this->_purgeArgsStackForTable($args, 'line');

        $content = $table_content;
    }
972816
public static function th(
        string $content = null, 
        array $attributes = []
    ) : string 
    {
        return self::tag("th", $content, $attributes);
    }
1009010
private function extractTagIds(SiteContent $content, array $fields)
    {
        $tagsIdsGrouped = [[]];

        foreach ($fields as $identifier) {
            if (!$content->hasField($identifier)) {
                throw new InvalidArgumentException(
                    "Content does not contain field '{$identifier}'"
                );
            }

            $field = $content->getField($identifier);

            if ($field->fieldTypeIdentifier !== 'eztags') {
                throw new InvalidArgumentException(
                    "Field '{$identifier}' is not of 'eztags' type"
                );
            }

            /** @var $value \Netgen\TagsBundle\Core\FieldType\Tags\Value */
            $value = $field->value;
            $tagsIdsGrouped[] = array_map(function (Tag $tag) {return $tag->id;}, $value->tags);
        }

        return array_merge(...$tagsIdsGrouped);
    }
1146459
protected function _doTableLine(&$content, array &$args = array(), $scope = 'body')
    {
        $my_line = '';
        $cell_args = $this->_getArgsStackForTable($args, 'cell', $scope);
        $cell_tag = 'table_'.$scope.'_cell';
        foreach($content as $cell) {
            $my_line .= $this->_tagComposer($cell, $cell_tag, $cell_args);
        }
        $line_args = $this->_getArgsStackForTable($args, 'line', $scope);
        $line_tag = 'table_'.$scope.'_line';
        $content = $this->_tagComposer($my_line, $line_tag, $line_args);
    }
483674
public static function compileContent($content, array $data, $param)
    {
        if (is_string($content)) {
            return static::compileBlade($content, static::getMixedValue($data, $param));
        } elseif (is_callable($content)) {
            return $content($param);
        }

        return $content;
    }
1275546
protected function extractMediasFromContent(ContentInterface $content)
    {
        $references = array();

        /** @var ContentAttributeInterface $attribute */
        foreach ($content->getAttributes() as $attribute) {
            $references = array_merge($references, $this->extractMediasFromElement($attribute->getValue()));
        }

        return $references;
    }
1100314
public function normalize(
        Content $content,
        ThemeInterface $theme,
        TemplateInterface $template,
        ZoneInterface $zone,
        ComponentInterface $component
    ) {
        return array('_s_context' => array(
            'content' => array($content->getType()->getName(), $content->getContentId()),
            'theme' => $theme->getName(),
            'template' => $template->getId(),
            'zone' => $zone->getId(),
            'component' => $component->getId(),
        ));
    }
700525
public function addContent(string $content, string $contentType, ?string $charset = null): Message
    {
        $charset = $charset ?: $this->getCharset();

        $this->content[] = [
            'content'      => $content,
            'content_type' => $contentType,
            'charset'      => $charset
        ];

        return $this;
    }
174482
public function process($content, array $options = [])
    {
        $tagNames = array_keys($this->tags);
        $tagNames[] = 'component';
        if (is_string($content)) {
            $found = false;
            foreach ($tagNames as $tagName) {
                if (strpos($content, '<' . $tagName) !== false) {
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                return $content;
            }
        } elseif (!($content instanceof \IvoPetkov\HTMLServerComponent)) {
            throw new \InvalidArgumentException('');
        }

        $getComponentFileContent = static function($file, $component, $variables) {
            if (is_file($file)) {
                $__componentFile = $file;
                unset($file);
                if (!empty($variables)) {
                    extract($variables, EXTR_SKIP);
                }
                unset($variables);
                ob_start();
                include $__componentFile;
                $content = ob_get_clean();
                return $content;
            } else {
                throw new \Exception('Component file cannot be found (' . $file . ')');
            }
        };

        $getComponentResultHTML = function($component) use (&$getComponentFileContent, $options) {
            $srcAttributeValue = $component->getAttribute('src');
            if ($srcAttributeValue === null) {
                if (isset($this->tags[$component->tagName])) {
                    $srcAttributeValue = $this->tags[$component->tagName];
                } else {
                    throw new \Exception('Component tag name is not defined at ' . (string) $component . '!');
                }
            }
            if ($srcAttributeValue !== null) {
                // todo check alias of alias
                if (isset($this->aliases[$srcAttributeValue])) {
                    $sourceParts = explode(':', $this->aliases[$srcAttributeValue], 2);
                } else {
                    $sourceParts = explode(':', $srcAttributeValue, 2);
                }
                if (isset($sourceParts[0], $sourceParts[1])) {
                    $scheme = $sourceParts[0];
                    if ($scheme === 'data') {
                        if (substr($sourceParts[1], 0, 7) === 'base64,') {
                            return base64_decode(substr($sourceParts[1], 7)); //$this->process(, isset($componentOptions) ? $componentOptions : $options);
                        }
                        throw new \Exception('Components data URI scheme only supports base64 (data:base64,ABCD...)!');
                    } elseif ($scheme === 'file') {
                        return $getComponentFileContent(urldecode($sourceParts[1]), $component, isset($options['variables']) && is_array($options['variables']) ? $options['variables'] : []); //$this->process(isset($componentOptions) ? $componentOptions : $options);
                    }
                    throw new \Exception('Components URI scheme not valid! It must be \'file:\', \'data:\' or an alias.');
                }
                throw new \Exception('Components URI scheme or alias not found at ' . (string) $component . '!');
            }
            throw new \Exception('Component src attribute is missing at ' . (string) $component . '!');
        };

        $disableLevelProcessing = false;
        $domDocument = new HTML5DOMDocument();
        if ($content instanceof \IvoPetkov\HTMLServerComponent) {
            $domDocument->loadHTML($getComponentResultHTML($content), HTML5DOMDocument::ALLOW_DUPLICATE_IDS);
            if (isset($options['recursive']) && $options['recursive'] === false) {
                $disableLevelProcessing = true;
            }
        } else {
            $domDocument->loadHTML($content, HTML5DOMDocument::ALLOW_DUPLICATE_IDS);
        }
        if (!$disableLevelProcessing) {
            $tagsQuerySelector = implode(',', $tagNames);
            for ($level = 0; $level < 1000; $level++) {
                $componentElements = $domDocument->querySelectorAll($tagsQuerySelector);
                if ($componentElements->length === 0) {
                    break;
                }
                $insertHTMLSources = [];
                $list = []; // Save the elements into an array because removeChild() messes up the NodeList
                foreach ($componentElements as $componentElement) {
                    $isInOtherComponentTag = false;
                    $parentNode = $componentElement->parentNode;
                    while ($parentNode !== null && isset($parentNode->tagName)) {
                        if (array_search($parentNode->tagName, $tagNames) !== false) {
                            $isInOtherComponentTag = true;
                            break;
                        }
                        $parentNode = $parentNode->parentNode;
                    }
                    if (!$isInOtherComponentTag) {
                        $list[] = $componentElement;
                    }
                }
                foreach ($list as $i => $componentElement) {
                    $component = $this->makeComponent($componentElement->getAttributes(), $componentElement->innerHTML, $componentElement->tagName);
                    $componentResultHTML = $getComponentResultHTML($component);
                    $isInBodyTag = false;
                    $parentNode = $componentElement->parentNode;
                    while ($parentNode !== null && isset($parentNode->tagName)) {
                        if ($parentNode->tagName === 'body') {
                            $isInBodyTag = true;
                            break;
                        }
                        $parentNode = $parentNode->parentNode;
                    }
                    if ($isInBodyTag) {
                        $insertTargetName = 'html-server-components-compiler-insert-target-' . $i;
                        $componentElement->parentNode->insertBefore($domDocument->createInsertTarget($insertTargetName), $componentElement);
                        $componentElement->parentNode->removeChild($componentElement); // must be before insertHTML because a duplicate elements IDs can occur.
                        $insertHTMLSources[] = ['source' => $componentResultHTML, 'target' => $insertTargetName];
                    } else {
                        $componentElement->parentNode->removeChild($componentElement);
                        $insertHTMLSources[] = ['source' => $componentResultHTML];
                    }
                }
                $domDocument->insertHTMLMulti($insertHTMLSources);
                if (isset($options['recursive']) && $options['recursive'] === false) {
                    break;
                }
            }
        }

        $domDocument->modify(
                HTML5DOMDocument::FIX_MULTIPLE_TITLES |
                HTML5DOMDocument::FIX_DUPLICATE_METATAGS |
                HTML5DOMDocument::FIX_MULTIPLE_HEADS |
                HTML5DOMDocument::FIX_MULTIPLE_BODIES |
                HTML5DOMDocument::OPTIMIZE_HEAD
        );
        return $domDocument->saveHTML();
    }
593522
public function contentTag($name, $content, array $options = array(), $escape = false)
    {
        if ($content instanceof \Closure) {
            ob_start();
            $ret     = $content();
            $content = ob_get_clean();
            if ($ret !== null) {
                $content = $ret;
            }
        }
        return $this->contentTagString($name, $content, $options, $escape);
    }