resolveEntityValueToString example

$text = new TextStruct();
        $slot->setData($text);

        $config = $slot->getFieldConfig()->get('content');
        if ($config === null) {
            return;
        }

        $content = null;

        if ($config->isMapped() && $resolverContext instanceof EntityResolverContext) {
            $content = $this->resolveEntityValueToString($resolverContext->getEntity()$config->getStringValue()$resolverContext);
        }

        if ($config->isStatic()) {
            if ($resolverContext instanceof EntityResolverContext) {
                $content = (string) $this->resolveEntityValues($resolverContext$config->getStringValue());
            } else {
                $content = $config->getStringValue();
            }
        }

        if ($content !== null) {
            
return $criteria;
    }

    protected function resolveEntityValues(EntityResolverContext $resolverContext, string $content): ?string
    {
        // https://regex101.com/r/idIfbk/1         $content = preg_replace_callback(
            '/{{\s*(?<property>[\w.\d]+)\s*}}/',
            function D$matches) use ($resolverContext) {
                try {
                    return $this->resolveEntityValueToString($resolverContext->getEntity()$matches['property']$resolverContext);
                } catch (\InvalidArgumentException) {
                    return $matches[0];
                }
            },
            $content
        );

        return $content;
    }

    private function getKeyByManyToMany(ManyToManyAssociationField $field): ?string
    {
Home | Imprint | This part of the site doesn't use cookies.