{@inheritDoc}

@since 2.5RC1
499234
@Override
    public void beginLink(ResourceReference reference, boolean freestanding, Map<String, String> parameters)
    {
        for (Listener listener : this.listeners) {
            listener.beginLink(reference, freestanding, parameters);
        }
    }
1089294
public function process($input)
    {
        list($l, $r) = $this->compiler->getDelimiters();

        $rl           = preg_quote($l, '/');
        $rr           = preg_quote($r, '/');
        $sectionParam = '(?:(name|loop|start|step|max|show)\s*=\s*(\S+))?\s*';
        $input        = preg_replace_callback('/' . $rl . '\s*section ' . str_repeat($sectionParam, 6) . '\s*' . $rr . '(.+?)(?:' . $rl . '\s*sectionelse\s*' . $rr . '(.+?))?' . $rl . '\s*\/section\s*' . $rr . '/is', array(
            $this,
            'convertSection'
        ), $input);
        $input        = str_replace('$smarty.section.', '$smarty.for.', $input);

        $smarty = array(
            '/' . $rl . '\s*ldelim\s*' . $rr . '/',
            '/' . $rl . '\s*rdelim\s*' . $rr . '/',
            '/' . $rl . '\s*\$smarty\.ldelim\s*' . $rr . '/',
            '/' . $rl . '\s*\$smarty\.rdelim\s*' . $rr . '/',
            '/\$smarty\./',
            '/' . $rl . '\s*php\s*' . $rr . '/',
            '/' . $rl . '\s*\/php\s*' . $rr . '/',
            '/\|(@?)strip(\||' . $rr . ')/',
            '/' . $rl . '\s*sectionelse\s*' . $rr . '/',
        );

        $dwoo = array(
            '\\' . $l,
            $r,
            '\\' . $l,
            $r,
            '$dwoo.',
            '<?php ',
            ' ?>',
            '|$1whitespace$2',
            $l . 'else' . $r,
        );

        if (preg_match('{\|@([a-z][a-z0-9_]*)}i', $input, $matches)) {
            trigger_error('The Smarty Compatibility Module has detected that you use |@' . $matches[1] . ' in your template, this might lead to problems as Dwoo interprets the @ operator differently than Smarty, see http://wiki.dwoo.org/index.php/Syntax#The_.40_Operator', E_USER_NOTICE);
        }

        return preg_replace($smarty, $dwoo, $input);
    }
478087
protected function initTag()
    {
        parent::initTag();

        $value = preg_split('/[\s]+/', $this->description, 3);

        if (isset($value[0]) === true && trim($value[0]) !== '') {
            $this->paramType = trim($value[0]);
        }

        if (isset($value[1]) === true && trim($value[1]) !== '') {
            $this->paramName = trim($value[1]);
            if (strpos($this->paramName, '$') !== 0) {
                throw new RuntimeException('The name of the parameter does not start with "$".');
            }
        }
        if (isset($value[2]) === true && trim($value[2]) !== '') {
            $this->paramDescription = trim($value[2]);
        }
    }
462626
@Override
	public void onEnd(TestContext<Object> context) {
		try {
			System.setErr(oldErr);
			System.setOut(oldOut);
		} catch (SecurityException e) {
			// ignored
		}
	}
431207
public function set($key, $value, $expireResolution = null, $expireTTL = null, $flag = null)
    {
        $expireResolution = strtolower($expireResolution);
        $expireTTL = strtolower($expireTTL);

        $condition = null;
        $ttl = 0;
        if (in_array($expireResolution, array('nx', 'xx'))) {
            $condition = $expireResolution;
            if ($expireTTL === 'ex') {
                $ttl = $flag;
            } elseif ($expireTTL === 'px') {
                $ttl = ceil($flag / 1000);
            }
        } else {
            if ($expireResolution === 'ex') {
                $ttl = $expireTTL;
            } elseif ($expireResolution === 'px') {
                $ttl = ceil($expireTTL / 1000);
            }
        }

        if ($condition === 'nx' && $this->doExists($key)) {
            return null;
        }
        if ($condition === 'xx' && !$this->doExists($key)) {
            return null;
        }

        $this->data[$key] = $value;
        if ($ttl > 0) {
            $this->expiring[$key] = $this->getTimestamp() + $ttl;
        }

        return 'OK';
    }
52243
private function initializeDoctrine()
    {
        if ($this->cm !== null) {
            return;
        }

        if (! self::$entityManager) {
            throw new RuntimeException('No runtime entity manager set. Call PersistentObject#setEntityManager().');
        }

        $this->cm = self::$entityManager->getClassMetadata(static::class);
    }
107062
function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement )
    {
        $dom = $namedParameters['dom'];
        if ( $dom instanceof eZContentObjectAttribute )
        {
            $this->ObjectAttributeId = $dom->attribute( 'id' );
            $content = $dom->attribute( 'content' );
            $xmlData = $content->attribute( 'xml_data' );

            $domTree = new DOMDocument( '1.0', 'utf-8' );
            $domTree->preserveWhiteSpace = false;
            $success = $domTree->loadXML( $xmlData );

            $tocText = '';
            if ( $success )
            {
                $this->HeaderCounter = array();
                $this->LastHeaderLevel = 0;

                $rootNode = $domTree->documentElement;
                $tocText .= $this->handleSection( $rootNode );

                while ( $this->LastHeaderLevel > 0 )
                {
                    $tocText .= "</li>\n</ul>\n";
                    $this->LastHeaderLevel--;
                }
            }
        }
        $operatorValue = $tocText;
    }
929620
public function documentMethod(\ReflectionClass $rClass, \ReflectionMethod $rMethod, array &$methodDoc) {
    parent::documentMethod($rClass, $rMethod, $methodDoc);

    if (!$this->doesHaveAccessToMethod($rMethod->name)) {
      $methodDoc = NULL;
      return;
    }

    if (!empty($this->next)) {
      $this->next->documentMethod($rClass, $rMethod, $methodDoc);
    }
  }
885620
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        switch ( $functionName )
        {
            case $this->BlockName:
            {
                // Check for disabled cache.
                $ini = eZINI::instance();
                if ( $ini->variable( 'TemplateSettings', 'TemplateCache' ) != 'enabled' )
                {
                    $text = eZTemplateCacheFunction::processUncached( $tpl, $functionChildren,
                                                                      $rootNamespace, $currentNamespace );
                    $textElements[] = $text;
                    return;
                }
                else
                {
                    $text = eZTemplateCacheFunction::processCachedPreprocess( $tpl,  $functionChildren,
                                                                              $functionParameters, $functionPlacement,
                                                                              $rootNamespace, $currentNamespace );
                    $textElements[] = $text;
                }
            } break;
        }
    }
1096045
function updateChildrenUri()
    {
        foreach ($this->_children as $child_name => $child){
            /* @var Entity $child */
            $child->_attributes['uri'] = $this->_attributes['uri'].'/'.$child_name;
            $child->_attributes['parent'] = $this->_attributes['uri'];
            $child->updateChildrenUri();
        }
    }
431648
public function update()
    {
        $snapshot = $this->_snapshot;
        if ($snapshot === false) {
            throw new PreconditionException(['update failed: `:model` instance is snapshot disabled', 'model' => static::class]);
        }

        $primaryKeyValuePairs = $this->_getPrimaryKeyValuePairs();

        $fieldTypes = $this->getFieldTypes();
        $fields = array_keys($fieldTypes);

        $changedFields = [];
        foreach ($fields as $field) {
            if ($this->$field === null) {
                /** @noinspection NotOptimalIfConditionsInspection */
                if (isset($snapshot[$field])) {
                    $changedFields[] = $field;
                }
            } elseif (!isset($snapshot[$field])) {
                if (is_scalar($this->$field)) {
                    $this->$field = $this->normalizeValue($fieldTypes[$field], $this->$field);
                }
                $changedFields[] = $field;
            } elseif ($snapshot[$field] !== $this->$field) {
                if (is_scalar($this->$field)) {
                    $this->$field = $this->normalizeValue($fieldTypes[$field], $this->$field);
                }

                /** @noinspection NotOptimalIfConditionsInspection */
                if ($snapshot[$field] !== $this->$field) {
                    $changedFields[] = $field;
                }
            }
        }

        if (!$changedFields) {
            return $this;
        }

        $this->validate($changedFields);

        foreach ($this->getAutoFilledData(self::OP_UPDATE) as $field => $value) {
            if (in_array($field, $fields, true)) {
                $this->$field = $value;
            }
        }

        $this->eventsManager->fireEvent('model:beforeSave', $this);
        $this->eventsManager->fireEvent('model:beforeUpdate', $this);

        $fieldValues = [];
        foreach ($fields as $field) {
            if ($this->$field === null) {
                if (isset($snapshot[$field])) {
                    $fieldValues[$field] = null;
                }
            } elseif (!isset($snapshot[$field]) || $snapshot[$field] !== $this->$field) {
                $fieldValues[$field] = $this->$field;
            }
        }

        foreach ($primaryKeyValuePairs as $key => $value) {
            unset($fieldValues[$key]);
        }

        if (!$fieldValues) {
            return $this;
        }

        foreach ($this->getJsonFields() as $field) {
            if (isset($fieldValues[$field]) && is_array($fieldValues[$field])) {
                $fieldValues[$field] = json_encode($fieldValues[$field], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
            }
        }

        $query = static::query(null, $this)->where($primaryKeyValuePairs);
        $query->update($fieldValues);

        $expressionFields = [];
        foreach ($fieldValues as $field => $value) {
            if ($value instanceof ExpressionInterface) {
                $expressionFields[] = $field;
            }
        }

        if ($expressionFields) {
            $expressionFields['_id'] = false;
            if ($rs = $query->select($expressionFields)->execute()) {
                foreach ((array)$rs[0] as $field => $value) {
                    $this->$field = $value;
                }
            }
        }

        $this->_snapshot = $this->toArray();

        $this->eventsManager->fireEvent('model:afterUpdate', $this);
        $this->eventsManager->fireEvent('model:afterSave', $this);

        return $this;
    }
336860
public function resetTermsStream(/** $startId = 0, $mode = self::SM_TERMS_ONLY */)
    {
        /**
         * SegmentInfo->resetTermsStream() method actually takes two optional parameters:
         *   $startId (default value is 0)
         *   $mode (default value is self::SM_TERMS_ONLY)
         */
        $argList = func_get_args();
        if (count($argList) > 2) {
            require_once 'Zend/Search/Lucene/Exception.php';
            throw new Zend_Search_Lucene_Exception('Wrong number of arguments');
        } else if (count($argList) == 2) {
            $startId = $argList[0];
            $mode    = $argList[1];
        } else if (count($argList) == 1) {
            $startId = $argList[0];
            $mode    = self::SM_TERMS_ONLY;
        } else {
            $startId = 0;
            $mode    = self::SM_TERMS_ONLY;
        }

        if ($this->_tisFile !== null) {
            $this->_tisFile = null;
        }

        $this->_tisFile = $this->openCompoundFile('.tis', false);
        $this->_tisFileOffset = $this->_tisFile->tell();

        $tiVersion = $this->_tisFile->readInt();
        if ($tiVersion != (int)0xFFFFFFFE /* pre-2.1 format */  &&
            $tiVersion != (int)0xFFFFFFFD /* 2.1+ format    */) {
            require_once 'Zend/Search/Lucene/Exception.php';
            throw new Zend_Search_Lucene_Exception('Wrong TermInfoFile file format');
        }

        $this->_termCount     =
              $this->_termNum = $this->_tisFile->readLong(); // Read terms count
        $this->_indexInterval = $this->_tisFile->readInt();  // Read Index interval
        $this->_skipInterval  = $this->_tisFile->readInt();  // Read skip interval
        if ($tiVersion == (int)0xFFFFFFFD /* 2.1+ format */) {
            $maxSkipLevels = $this->_tisFile->readInt();
        }

        if ($this->_frqFile !== null) {
            $this->_frqFile = null;
        }
        if ($this->_prxFile !== null) {
            $this->_prxFile = null;
        }
        $this->_docMap = array();

        $this->_lastTerm          = new Zend_Search_Lucene_Index_Term('', -1);
        $this->_lastTermInfo      = new Zend_Search_Lucene_Index_TermInfo(0, 0, 0, 0);
        $this->_lastTermPositions = null;

        $this->_termsScanMode = $mode;

        switch ($mode) {
            case self::SM_TERMS_ONLY:
                // Do nothing
                break;

            case self::SM_FULL_INFO:
                // break intentionally omitted
            case self::SM_MERGE_INFO:
                $this->_frqFile = $this->openCompoundFile('.frq', false);
                $this->_frqFileOffset = $this->_frqFile->tell();

                $this->_prxFile = $this->openCompoundFile('.prx', false);
                $this->_prxFileOffset = $this->_prxFile->tell();

                for ($count = 0; $count < $this->_docCount; $count++) {
                    if (!$this->isDeleted($count)) {
                        $this->_docMap[$count] = $startId + (($mode == self::SM_MERGE_INFO) ? count($this->_docMap) : $count);
                    }
                }
                break;

            default:
                require_once 'Zend/Search/Lucene/Exception.php';
                throw new Zend_Search_Lucene_Exception('Wrong terms scaning mode specified.');
                break;
        }

        // Calculate next segment start id (since $this->_docMap structure may be cleaned by $this->nextTerm() call)
        $nextSegmentStartId = $startId + (($mode == self::SM_MERGE_INFO) ? count($this->_docMap) : $this->_docCount);
        $this->nextTerm();

        return $nextSegmentStartId;
    }
342246
public function Bind()
	{
		if ( $this->getCount() > 0)
		{
			if ( $this->getAbstractNode(0) instanceof PathExprNode )
			{
				/**
				 * @var PathExprNode $pathExpr
				 */
				$pathExpr = $this->getAbstractNode(0);
				if ( in_array( $this->_name, FuncNode::$s_aggregates ) && $this->_ns == XmlReservedNs::xQueryFunc )
				{
					$pathExpr->Unordered = true;
				}
			}
		}
		parent::Bind();
	}
355347
public function getStmt()
    {
        // Make sure there are no nested arrays
        if (ArrayUtils::hasAtLeastOneArrayValue($this->bindings)) {
            throw new RuntimeException('PDO bindings can not contain nested arrays');
        }

        // Build target query before bindings are cleared purely for logging purpose
        $log = str_replace(array_keys($this->bindings), array_values($this->bindings), $this->queryBuilder->getQueryString());

        // Execute it
        $stmt = $this->pdo->prepare($this->queryBuilder->getQueryString());
        $stmt->execute($this->bindings);

        // Log target query
        $this->queryLogger->add($log);

        // Clear the buffer
        $this->clear();

        return $stmt;
    }
693045
public function normalize($object, $format = null, array $context = [])
    {
        if ($object !== $transformed = $this->transformOutput($object, $context)) {
            if (!$this->serializer instanceof NormalizerInterface) {
                throw new LogicException('Cannot normalize the transformed value because the injected serializer is not a normalizer');
            }

            $context['api_normalize'] = true;
            $context['api_resource'] = $object;
            unset($context['output']);

            return $this->serializer->normalize($transformed, $format, $context);
        }

        // Use resolved resource class instead of given resource class to support multiple inheritance child types
        $resourceClass = $this->resourceClassResolver->getResourceClass($object, $context['resource_class'] ?? null, true);
        $context = $this->initContext($resourceClass, $context);
        $iri = $context['iri'] ?? $this->iriConverter->getIriFromItem($object);
        $context['iri'] = $iri;
        $context['api_normalize'] = true;

        /*
         * When true, converts the normalized data array of a resource into an
         * IRI, if the normalized data array is empty.
         *
         * This is useful when traversing from a non-resource towards an attribute
         * which is a resource, as we do not have the benefit of {@see PropertyMetadata::isReadableLink}.
         *
         * It must not be propagated to subresources, as {@see PropertyMetadata::isReadableLink}
         * should take effect.
         */
        $emptyResourceAsIri = $context['api_empty_resource_as_iri'] ?? false;
        unset($context['api_empty_resource_as_iri']);

        if (isset($context['resources'])) {
            $context['resources'][$iri] = $iri;
        }

        $data = parent::normalize($object, $format, $context);
        if ($emptyResourceAsIri && \is_array($data) && 0 === \count($data)) {
            return $iri;
        }

        return $data;
    }
556945
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        $params = $functionParameters;
        switch ( $functionName )
        {
            case $this->BlockName:
            {
                $viewMode = "full";
                $name = $currentNamespace;
                // Read ini file
                $toolbarIni = eZINI::instance( "toolbar.ini" );

                if ( isset( $functionParameters["view"] ) )
                {
                    $viewMode = $tpl->elementValue( $functionParameters["view"], $rootNamespace, $currentNamespace, $functionPlacement );
                }

                if ( isset( $functionParameters["name"] ) )
                {
                    reset( $params );
                    $whatParamsShouldBeUnset = array();
                    $whatParamsShouldBeReplaced = array();
                    while ( ( $key = key( $params ) ) !== null )
                    {
                        $item =& $params[$key];
                        switch ( $key )
                        {
                            case "name":
                            case "view":
                                break;

                            default:
                            {
                                if ( !$tpl->hasVariable( $key, $name ) )
                                {
                                    $whatParamsShouldBeUnset[] = $key; // Tpl vars should be removed after including
                                }
                                else
                                {
                                    $whatParamsShouldBeReplaced[$key] = $tpl->variable( $key, $name ); // Tpl vars should be replaced after including
                                }

                                $item_value = $tpl->elementValue( $item, $rootNamespace, $currentNamespace, $functionPlacement );
                                $tpl->setVariable( $key, $item_value, $name );
                            } break;
                        }
                        next( $params );
                    }
                    $toolbarPosition = $tpl->elementValue( $functionParameters["name"], $rootNamespace, $currentNamespace, $functionPlacement );
                    $definedVariables = array();
                    $toolbarName = "Toolbar_" . $toolbarPosition;
                    $toolArray = $toolbarIni->variable( $toolbarName, 'Tool' );

                    if ( !is_array( $toolArray ) )
                        $toolArray = array();

                    $actionParameters = array();
                    foreach ( array_keys( $toolArray ) as $toolKey )
                    {
                        $definedVariables = array();
                        $tool = $toolArray[$toolKey];
                        $placement = $toolKey + 1;
                        if ( $toolbarIni->hasGroup( "Tool_" . $tool ) )
                        {
                            $actionParameters = $toolbarIni->group( "Tool_" . $tool );
                        }
                        if ( $toolbarIni->hasGroup( "Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement ) )
                        {
                            $actionParameters = array_merge( $actionParameters, $toolbarIni->group( "Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement ) );
                        }
                        foreach ( array_keys( $actionParameters ) as $key )
                        {
                            $itemValue = $actionParameters[$key];
                            $tpl->setVariable( $key, $itemValue, $name );
                            $definedVariables[] = $key;
                        }
                        $toolIDValue =  "Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement;
                        $tpl->setVariable( "tool_id", $toolIDValue, $name );
                        $definedVariables[] = "tool_id";
                        $toolOffset = $placement;
                        $tpl->setVariable( "offset", $toolOffset, $name );
                        $definedVariables[] = "offset";
                        $uri = "design:toolbar/$viewMode/$tool.tpl";

                        if ( $placement == 1 )
                        {
                            if ( count( $toolArray ) == 1 )
                            {
                                $tpl->setVariable( "first", true );
                                $tpl->setVariable( "last", true );
                                $tpl->setVariable( "placement", "last" );
                                $definedVariables[] = "first";
                                $definedVariables[] = "last";
                                $definedVariables[] = "placement";
                            }
                            else
                            {
                                $tpl->setVariable( "first", true );
                                $tpl->setVariable( "last", false );
                                $tpl->setVariable( "placement", "first" );
                                $definedVariables[] = "first";
                                $definedVariables[] = "last";
                                $definedVariables[] = "placement";
                            }
                        }
                        else if ( $placement == count( $toolArray ) )
                        {
                            $tpl->setVariable( "first", false );
                            $tpl->setVariable( "last", true );
                            $tpl->setVariable( "placement", "last" );
                            $definedVariables[] = "first";
                            $definedVariables[] = "last";
                            $definedVariables[] = "placement";
                        }
                        else
                        {
                            $tpl->setVariable( "first", false );
                            $tpl->setVariable( "last",  false );
                            $tpl->setVariable( "placement", "" );
                            $definedVariables[] = "placement";
                        }
                        $tpl->processURI( $uri, true, $extraParameters, $textElements, $name, $name );
                        // unset var
                        foreach ( $whatParamsShouldBeUnset as $key )
                        {
                            $tpl->unsetVariable( $key, $name );
                        }
                        // replace var
                        foreach ( $whatParamsShouldBeReplaced as $key => $item_value )
                        {
                            $tpl->setVariable( $key, $item_value, $name );
                        }
                    }
                }
            }
        }
    }
290015
public function build(): SetEffectivePropertyValueForNodeRequest
	{
		$instance = new SetEffectivePropertyValueForNodeRequest();
		if ($this->nodeId === null) {
			throw new BuilderException('Property [nodeId] is required.');
		}
		$instance->nodeId = $this->nodeId;
		if ($this->propertyName === null) {
			throw new BuilderException('Property [propertyName] is required.');
		}
		$instance->propertyName = $this->propertyName;
		if ($this->value === null) {
			throw new BuilderException('Property [value] is required.');
		}
		$instance->value = $this->value;
		return $instance;
	}