{@inheritDoc}

@since 2.5RC1
540689
@Override
    public void onImage(ResourceReference reference, boolean freestanding, Map<String, String> parameters)
    {
        saveEvent(EventType.ON_IMAGE, reference, freestanding, parameters);
    }
69953
public function convertUriToObject($uri, NodeInterface $contextNode = null)
    {
        if ($uri instanceof Uri) {
            $uri = (string)$uri;
        }

        if (preg_match(self::PATTERN_SUPPORTED_URIS, $uri, $matches) === 1) {
            switch ($matches[1]) {
                case 'node':
                    if ($contextNode === null) {
                        throw new \RuntimeException('node:// URI conversion requires a context node to be passed', 1409734235);
                    };

                    return $contextNode->getContext()->getNodeByIdentifier($matches[2]);
                case 'asset':
                    return $this->assetRepository->findByIdentifier($matches[2]);
            }
        }

        return null;
    }
1266894
function resourceData( $resourceObject, $uri, $resourceName, $templateName )
    {
        $resourceData = array();
        $resourceData['uri'] = $uri;
        $resourceData['resource'] = $resourceName;
        $resourceData['template-name'] = $templateName;
        $resourceData['template-filename'] = $templateName;
        $resourceData['handler'] = $resourceObject;
        $resourceData['test-compile'] = $this->TestCompile;
        return $resourceData;
    }
1185564
public function createSrcfile()
    {
        if ($this->srcFilePos !== null) {
            throw new BuildException(
                $this->getTaskType() . " doesn\'t support multiple "
                . "srcfile elements.",
                $this->getLocation()
            );
        }

        $this->srcFilePos = $this->commandline->createMarker();
        return $this->srcFilePos;
    }
656760
public function process($file, $cache_time = null, $cache_id = null, $compile_id = null, $data = '_root', $assign = null, array $rest = array())
    {
        $include = null;
        if ($file === '') {
            return '';
        }

        if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) {
            // resource:identifier given, extract them
            $resource   = $m[1];
            $identifier = $m[2];
        } else {
            // get the current template's resource
            $resource   = $this->core->getTemplate()->getResourceName();
            $identifier = $file;
        }

        try {
            $include = $this->core->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id);
        }
        catch (SecurityException $e) {
            $this->core->triggerError('Include : Security restriction : ' . $e->getMessage(), E_USER_WARNING);
        }
        catch (Exception $e) {
            $this->core->triggerError('Include : ' . $e->getMessage(), E_USER_WARNING);
        }

        if ($include === null) {
            $this->core->triggerError('Include : Resource "' . $resource . ':' . $identifier . '" not found.',
                E_USER_WARNING);
        } elseif ($include === false) {
            $this->core->triggerError('Include : Resource "' . $resource . '" does not support includes.',
                E_USER_WARNING);
        }

        if (is_string($data)) {
            $vars = $this->core->readVar($data);
        } else {
            $vars = $data;
        }

        if (count($rest)) {
            $vars = $rest + $vars;
        }

        $clone = clone $this->core;
        $out   = $clone->get($include, $vars);

        if ($assign !== null) {
            $this->core->assignInScope($out, $assign);
        }

        foreach ($clone->getReturnValues() as $name => $value) {
            $this->core->assignInScope($value, $name);
        }

        if ($assign === null) {
            return $out;
        }
    }
1192888
public function setnx($key, $value, $cb = null)
    {
        $this->redis->setnx($this->config->redisprefix->value . $key, $value, $cb);
    }
285016
public function process($rawHtml, $name = '', $context = [], $environment = null)
    {

        try {
            $html5 = new HTML5();
            $document = $html5->loadHTML($rawHtml);

            /** @var ExtractorExtension $extractorExtension */
            $extractorExtension = $environment->getExtension(ExtractorExtension::class);
            foreach ($document->getElementsByTagName('link') as $linkTag) {
                /** @var DOMElement $linkTag */
                if ($linkTag->getAttribute('rel') == 'stylesheet') {
                    $tokenisedStylesheet = explode('?', $linkTag->getAttribute('href'));
                    $stylesheet = reset($tokenisedStylesheet);

                    if ($content = $this->fileCache->fetch($stylesheet)) {
                        $extractorExtension->addBaseRules($content);
                        continue;
                    }


                    if (($content = @file_get_contents($stylesheet)) !== false) {
                        $this->fileCache->save($stylesheet, $content);
                        $extractorExtension->addBaseRules($content);
                        continue;
                    }
                    if (($content = @file_get_contents($_SERVER['DOCUMENT_ROOT'] . $stylesheet)) !== false) {
                        $this->fileCache->save($stylesheet, $content);
                        $extractorExtension->addBaseRules($content);
                        continue;
                    }
                }
            }

        } catch (\Exception $exception) {
            error_log($exception->getMessage());
            return $rawHtml;
        }

        try {
            $criticalCss = $extractorExtension->buildCriticalCssFromSnippets();

            if (strlen($criticalCss) == 0) {
                return $rawHtml;
            }
        } catch (Twig_Error_Runtime $tew) {
            error_log($tew->getMessage());
            return $rawHtml;
        }

        try {
            $headStyle = new DOMElement('style', $criticalCss);
            $document->getElementsByTagName('head')->item(0)->appendChild($headStyle);

            return $html5->saveHTML($document);
        } catch (\Exception $exception) {
            error_log($exception->getMessage());
            return $rawHtml;
        }
    }
941432
public function checkChildren($table, array $row, $level, array &$theData, DatabaseRecordListXclass $parentObj)
    {
        if ($table === 'tt_content' && $row['CType'] === 'gridelements_pi1') {
            $elementChildren = Helper::getInstance()->getChildren(
                $table,
                $row['uid'],
                $row['pid'],
                '',
                0,
                $parentObj->selFieldList
            );
            if (!empty($elementChildren)) {
                $theData['_EXPANDABLE_'] = true;
                $theData['_EXPAND_ID_'] = $table . ':' . $row['uid'];
                $theData['_EXPAND_TABLE_'] = $table;
                $theData['_LEVEL_'] = $level;
                $theData['_CHILDREN_'] = $elementChildren;
            }
        }
    }
258163
public function process(ContainerBuilder $container)
    {
        $taggedServiceIds = $container->findTaggedServiceIds('p2_ratchet.application');
        $events = array();

        foreach ($taggedServiceIds as $serviceId => $attributes) {
            $service = $container->getDefinition($serviceId);

            /** @var \P2\Bundle\RatchetBundle\WebSocket\ApplicationInterface $classname */
            $classname = $container->getParameterBag()->resolveValue($service->getClass());

            $eventList = array_keys($classname::getSubscribedEvents());
            $events = array_merge($events, $eventList);
        }

        $container
            ->getDefinition('p2_ratchet.websocket.server_bridge')
            ->addMethodCall('setAllowedEvents', array($events));
    }
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]);
        }
    }
364624
@Override
  /*!#if ($TemplateOptions.KTypePrimitive)
  public KType [] toArray()
     #else !*/
  public Object[] toArray()
  /*! #end !*/
  {
    KType[] array = Intrinsics.<KType> newArray(size());
    int i = 0;
    for (KTypeCursor<KType> c : this) {
      array[i++] = c.value;
    }
    return array;
  }
858421
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        $params = $functionParameters;
        switch ( $functionName )
        {
            case $this->BlockName:
            {
                $name ="";
                $menuIni = eZINI::instance( "menu.ini" );

                if ( isset( $functionParameters["name"] ) )
                {
                    $menuName = $tpl->elementValue( $functionParameters["name"], $rootNamespace, $currentNamespace, $functionPlacement );
                    if ( $menuIni->hasVariable( 'SelectedMenu', $menuName ) )
                    {
                        $menuTemplate = $menuIni->variable( 'SelectedMenu', $menuName );
                        if ( $menuTemplate != null )
                        {
                            $uri = "design:menu/$menuTemplate.tpl";
                            $tpl->processURI( $uri, true, $extraParameters, $textElements, $name, $name );
                        }
                    }
                }
            }
        }
    }
887154
public function process(ContainerBuilder $container): void
    {
        $collector = $container->findDefinition('fivelab.resource.serializer.context_collector');
        $services = $container->findTaggedServiceIds('resource.serializer.collector');

        foreach ($services as $serviceId => $tags) {
            try {
                $collectorDefinition = $container->getDefinition($serviceId);
                $collectorClass = $container->getParameterBag()->resolveValue($collectorDefinition->getClass());

                if (!is_a($collectorClass, SerializationContextCollectorInterface::class, true)) {
                    throw new \RuntimeException(sprintf(
                        'The serialization context collector should implement "%s".',
                        SerializationContextCollectorInterface::class
                    ));
                }

                $collector->addMethodCall('add', [
                    new Reference($serviceId),
                ]);
            } catch (\Exception $e) {
                throw new \RuntimeException(sprintf(
                    'Can\'t compile resource serialization collector with service id "%s".',
                    $serviceId
                ), 0, $e);
            }
        }
    }
1044099
public function triggerError($iErrorNumber = 0, $sErrorString = '', $sErrorFile = '', $iErrorLine = 0)
    {
        //  PHP5.6 doesn't like $this->sDriverClass::error()
        $sDriverClass = static::$sDriverClass;
        $sDriverClass::error($iErrorNumber, $sErrorString, $sErrorFile, $iErrorLine);
    }
982575
public function clear($action = null, $resource = null, $resourceId = null)
    {
        $actions = (array) $action;
        $resourceObject = $this->convertResourceToObject($resource, $resourceId);
        $permissions = $this->getPermissions();

        if ($action === null && $resource === null) {
            // Clear every permission for this lock instance.
            foreach ($permissions as $permission) {
                $this->removePermission($permission);
            }
        } elseif ($action === null && $resource !== null) {
            // Clear all permissions for a given resource.
            /** @todo Needs to be implemented */
        } else {
            // Clear every permission for the given actions.
            foreach ($actions as $action) {
                $this->clearPermission($action, $resourceObject, $permissions);
            }
        }
    }
736841
public function persist(PersistenceContext $context, ParentChildrenMap $map)
    {
        $primaryKey        = $map->getPrimaryKeyColumn();
        $relatedPrimaryKey = $this->mapper->getPrimaryTable()->getPrimaryKeyColumnName();
        $children          = $map->getAllChildren();
        $rows              = $this->reference->syncRelated($context, [], $children);

        /** @var Row[] $childRowMap */
        $childRowMap = [];
        foreach ($children as $key => $child) {
            $childRowMap[Identity::hash($child)] = $rows[$key];
        }

        // Clear join rows and reinsert to sync
        if ($map->hasAnyParentsWithPrimaryKeys()) {
            $delete = Delete::from($this->joinTable)
                ->where($this->getInvalidatedRelationExpr($map));
            $context->queue($delete);
        }

        $parentIdColumn  = $this->parentForeignKeyColumn->getName();
        $relatedIdColumn = $this->relatedForeignKeyColumn->getName();
        $joinTableRows   = [];

        foreach ($map->getItems() as $item) {
            $parent = $item->getParent();

            foreach ($item->getChildren() as $child) {
                $joinRow = new Row($this->joinTable);

                if ($parent->hasColumn($primaryKey)) {
                    $joinRow->setColumn($parentIdColumn, $parent->getColumn($primaryKey));
                } else {
                    $parent->onInsertPrimaryKey(function ($id) use ($joinRow, $parentIdColumn) {
                        $joinRow->setColumn($parentIdColumn, $id);
                    });
                }

                $childRow = $childRowMap[Identity::hash($child)];
                if ($childRow->hasColumn($relatedPrimaryKey)) {
                    $joinRow->setColumn($relatedIdColumn, $childRow->getColumn($relatedPrimaryKey));
                } else {
                    $childRow->onInsertPrimaryKey(function ($id) use ($joinRow, $relatedIdColumn) {
                        $joinRow->setColumn($relatedIdColumn, $id);
                    });
                }

                $joinTableRows[] = $joinRow;
            }
        }

        if (!empty($joinTableRows)) {
            $context->upsert(new RowSet($this->joinTable, $joinTableRows));
        }
    }
621504
public function resolveMapping($resource, $parameters = [], $key = 'default', $method = null)
	{
		$resourceName = $resource;

		if( is_object($resource) )
		{
			$resourceName = get_class($resource);
		}

		$mappings = $this->getMappings($resourceName, $key);

		if(empty($mappings))
		{
			throw new Exception('No resolvers mapped for resource: ' . $resourceName . '.');
		}

		$result = null;

		if(is_array($mappings))
		{
			return $this->runResolver($mappings[0], $parameters, $method);
		}

		return $this->runResolver($mappings, $parameters, $method);
	}