@param array  $context
@param int    $key
@param bool   $label
@param string $htmlTag
@param null   $data

@return string
@throws \Exception
428710
public function renderPlaceholder($context, $key = 0, $label = false, $htmlTag = 'div', $data = null)
    {
        if (isset($context['environment'])) {
            $this->blockEnvironment = $context['environment'];
        }

        $content = '';

        if ($this->blockEnvironment instanceof Environment) {
            if (isset($context['block'])) {
                /* @var BlockInterface $container */
                $container = $context['block'];
                if ($container instanceof CompositeBlock) {
                    $blocks = $this->blockEnvironment->getBlockChildren($container);
                } else {
                    throw new \Exception('Tried to render placeholder in a block which is not a CompositeBlock');
                }
            } else {
                $blocks = $this->blockEnvironment->getRootBlocks();
            }

            foreach ($blocks as $block) {
                if ($block->getPosition() === (int) $key || ((int) $key === 0 && $block->getPosition() === 0)) {
                    $content .= $this->renderBlock($block);
                }
            }

            if ($this->blockEnvironment->getBlockMode() === 'manage') {
                $data['class'] = 'pm-placeholder '.$data['class'];
            }

            $content = $this->container->get('templating')->render('OpiferContentBundle:Block/Layout:placeholder.html.twig', [
                'content' => $content,
                'tag' => $htmlTag,
                'data' => $data,
                'key' => $key,
                'id' => (isset($container)) ? $container->getId() : 0,
                'manage_type' => 'placeholder'
            ]);
        }

        return $content;
    }
680596
protected function syntax(string $key, array $data)
    {
        foreach ($data['directives'] ?? [] as $_key => $directive)
        {
            $this->data($_key, $directive ?: []);
        }

        $this->closed[$key] = $data['closed'] ?? false;
        $this->properties($data['properties'] ?? []);

        $syntax = [];

        foreach ($data['syntax'] ?? [] as $text)
        {
            $tokens = $this->lexer()->tokens($text);
            $vars   = $tokens[Lexer::PRINTER] ?? [];
            $code   = \str_replace(
                ['\\(', '\\)', ','],
                ['\\( ', ' \\)', ' ,'],
                $text
            );

            foreach ($vars as $var)
            {
                $code = \str_replace(
                    $var['code'],
                    $this->fragment($var['fragment']),
                    $code
                );
            }

            $syntax[] = [
                'vars'   => $vars,
                'regexp' => '~^' . $key . ' ' . $code . '$~ui'
            ];
        }

        return $syntax;
    }
1270510
public function encode($data, $format, array $context = [])
    {
        $jsonEncodeOptions = $context[self::OPTIONS] ?? $this->defaultContext[self::OPTIONS];
        $encodedJson = json_encode($data, $jsonEncodeOptions);

        if (JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($jsonEncodeOptions & JSON_PARTIAL_OUTPUT_ON_ERROR))) {
            throw new NotEncodableValueException(json_last_error_msg());
        }

        return $encodedJson;
    }
1137781
public static function btn($tag, $label, $htmlOptions = array())
    {
        ArrayHelper::addValue('class', 'button', $htmlOptions);

        $icon = ArrayHelper::removeValue($htmlOptions, 'icon');
        if (isset($icon))
            $label = Icon::icon($icon) . '&nbsp;' . $label;

        return \CHtml::tag($tag, $htmlOptions, $label);
    }
901890
public function visit($query, $node, string $context)
    {
        if ($node instanceof $this->node) {
            $bindings = [];
            $sql = [];

            $child0 = $node->getChildByIndex(0);

            if ($child0 instanceof Nodes\KeyNode) {
                $context === Nodes\OrNode::class && $query->orWhereNull($this->parseKey($child0->getValue()));
                $context === Nodes\AndNode::class && $query->whereNull($this->parseKey($child0->getValue()));
            }
        }
    }
213299
protected function get_option($key, $label, $counter, $data, array $fields = []){
        return sprintf('<label%6$s><input type="radio" name="%1$s" id="%1$s-%2$d" value="%3$s" %4$s /> %5$s </label>',
            $this->get_name(), $counter, esc_attr($key),
            checked( (!$data && $key == $this->default) || $key == $data , true, false),
            esc_html($label), $this->inline ? ' class="inline"' : '');
    }
8909
public function tag_add($tag, $key)
    {
        if ($this->stopwatch) {
            $e = $this->getStopwatchEvent('tag_add');
        }

        $result = parent::tag_add($tag, $key);

        if ($this->stopwatch) {
            $e->stop();
        }

        return $result;
    }
1332800
protected function get_option($key, $label, $counter, $data, array $fields = []){
        return sprintf('<option value="%s"%s>%s</option>',
            esc_attr($key),
            selected( (!$data && $key == $this->default) || $key == $data, true, false ),
            esc_html($label));
    }
1205190
private function appendNode(\DOMNode $parentNode, $data, string $nodeName, string $key = null): bool
    {
        $node = $this->dom->createElement($nodeName);
        if (null !== $key) {
            $node->setAttribute('key', $key);
        }
        $appendNode = $this->selectNodeType($node, $data);
        // we may have decided not to append this node, either in error or if its $nodeName is not valid
        if ($appendNode) {
            $parentNode->appendChild($node);
        }

        return $appendNode;
    }
828049
public function listing($key, $label)
    {
        $this->throwIfContextInvalid();

        $this->reloadQueryAdapter();
        $results = $this->activeQuery->listing($key, $label);

        $this->resetCurrentQuery();

        return $results;
    }
1127429
protected function getKey($key, $labelValues, $prefix = '')
    {
        if (is_array($labelValues)) {
            $labelHash = $this->getLabelHash($labelValues);
        } else {
            $labelHash = $labelValues;
        }
        return $this->getPrefix().'|'.$prefix.'|'.$key.'|'.$labelHash;
    }
799833
public static function setContextDataByKey(string $key, $val)
    {
        $coroutineId = self::getCoroutineId();
        self::$context[$coroutineId][self::DATA_KEY][$key] = $val;
    }
554235
public function post($key, $default = null, $htmlEntities = false)
    {
        if (!isset($_POST[$key])) {
            return $default;
        }

        return is_null($_POST[$key]) ? $default
            : $this->_escape($_POST[$key], $htmlEntities);
    }
381434
public static function make_label( $id, $key, $text = null, $attr = array() ) 
	{
		if ( is_null( $text ) )
		{
			$text = $key;
		}

		$element = HTML::tag( 'label', $text, array_merge( array( 
			'id' => $id, 
			'for' => static::build_id( 'input', $key ) 
		), $attr ));

		if ( !static::$builder_enabled )
		{
			 return $element;
		}

		return Builder::handle( 'form_label', $element );
	}
761251
private function loadTags(&$tags, \DOMXPath $xpath, \DOMNode $context = null)
    {
        $result = [];

        /** @var \DOMElement $node */
        foreach ($xpath->query('x:tag', $context) as $node) {
            $tag = $this->loadTag($xpath, $node);
            $this->validateTag($tag, $tags);

            $result[] = $tag;
        }

        return $result;
    }
224914
public static function setContextDataByChildKey(string $key, string $child, $val)
    {
        $coroutineId = self::getCoroutineId();
        self::$context[$coroutineId][self::DATA_KEY][$key][$child] = $val;
    }
703576
protected function _validateDataKey($key, $data)
    {
        $dataOkFlag = true;

        if (!$this->_validationOn) {
            return $dataOkFlag;
        }

        foreach ($this->_validationRules as $ruleKey => $ruleValue) {
            if (!preg_match($ruleKey, $key)) {
                continue;
            }

            $bool = $this->_validateData($ruleValue, $key, $data);
            if (!$bool) {
                $dataOkFlag = false;
            }
        }

        return $dataOkFlag;
    }