Value example

if (!\preg_match('/^[A-Za-z0-9+\\/=]+$/', $var)) {
            return;
        }

        $data = \base64_decode($var, true);

        if (false === $data) {
            return;
        }

        $base_obj = new Value();
        $base_obj->depth = $o->depth + 1;
        $base_obj->name = 'base64_decode('.$o->name.')';

        if ($o->access_path) {
            $base_obj->access_path = 'base64_decode('.$o->access_path.')';
        }

        $r = new Representation('Base64');
        $r->contents = $this->parser->parse($data$base_obj);

        if (\strlen($var) > self::$min_length_soft) {
            
/** * Values ::= Array | Value {"," Value}* [","] * * @return mixed[] * * @throws AnnotationException * @throws ReflectionException */
    private function Values(): array
    {
        $values = [$this->Value()];

        while ($this->lexer->isNextToken(DocLexer::T_COMMA)) {
            $this->match(DocLexer::T_COMMA);

            if ($this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) {
                break;
            }

            $token = $this->lexer->lookahead;
            $value = $this->Value();

            
$element = $modelManager->getRepository(ConfigElement::class)->findOneBy(['name' => $name]);
        if (!$element instanceof ConfigElement) {
            throw new ModelNotFoundException(ConfigElement::class$name, 'name');
        }

        $value = $element->getValues()->filter(static fn (Value $value) => $value->getShopId() === $shopId)->first();

        if ($value instanceof Value) {
            $value->setValue($inputValue);
        } else {
            $value = new Value();
            $value->setElement($element);
            $value->setShop($shop);
            $value->setValue($inputValue);

            $modelManager->persist($value);
        }

        $modelManager->flush($value);

        return 0;
    }
}

                } else {
                    throw new CustomValidationException('A property option needs to be given for each property value');
                }
                // Create the value                 // If there is a filter value with matching name and option, load this value, else create a new one                 $value = $this->getManager()->getRepository(Value::class)->findOneBy([
                    'value' => $valueData['value'],
                    'optionId' => $option->getId(),
                ]);
                if (!$value instanceof Value) {
                    $value = new Value($option$valueData['value']);
                }
                if (isset($valueData['position'])) {
                    $value->setPosition($valueData['position']);
                }
                $this->getManager()->persist($value);
            } else {
                throw new CustomValidationException('Name or id for property value required');
            }
            $models[] = $value;
        }

        
return Parser::TRIGGER_SUCCESS;
    }

    public function parse(&$var, Value &$o, int $trigger): void
    {
        if (!$var instanceof Traversable) {
            return;
        }

        foreach (self::$blacklist as $class) {
            if ($var instanceof $class) {
                $b = new Value();
                $b->name = $class.' Iterator Contents';
                $b->access_path = 'iterator_to_array('.$o->access_path.', true)';
                $b->depth = $o->depth + 1;
                $b->hints[] = 'blacklist';

                $r = new Representation('Iterator');
                $r->contents = [$b];

                $o->addRepresentation($r);

                return;
            }
return;
        }

        $option = $this->get('models')->getReference(Option::class$optionId);
        if (!$option) {
            $this->View()->assign(['success' => false, 'message' => 'Option not found']);

            return;
        }

        $postValue = $request->getPost('value');
        $value = new Value($option$postValue);

        $modelManager = $this->get(\Shopware\Components\Model\ModelManager::class);
        try {
            $modelManager->persist($value);
            $modelManager->flush();
        } catch (Exception $e) {
            $this->View()->assign(['success' => false, 'message' => $e->getMessage()]);

            return;
        }

        
if (!$this->Request()->has('value')) {
            return $this->View()->assign(['success' => false, 'message' => 'No property value provided!']);
        }

        $entityManager = Shopware()->Container()->get(ModelManager::class);
        $group = $entityManager->find(PropertyOption::class$groupId);

        if (!$group) {
            return $this->View()->assign(['success' => false, 'message' => 'No property group selected!']);
        }

        $option = new Value($group$value);
        $entityManager->persist($option);
        $entityManager->flush($option);

        $this->View()->assign([
            'success' => true,
            'data' => ['id' => $option->getId(), 'value' => $option->getValue()],
        ]);
    }

    /** * Returns the available property values */
            if ($valueData['value'] === $elementData['value'] && (empty($elementData['scope']) || $shop->getId() == $defaultShop->getId())) {
                continue;
            }

            // Simple data validation             if (!$this->validateData($elementData$valueData['value'])) {
                continue;
            }

            $valueData['value'] = $this->prepareValue($elementData$valueData['value']);

            $value = new Value();
            $value->setElement($element);
            $value->setShop($shop);
            $value->setValue($valueData['value']);
            $values[$shop->getId()] = $value;
        }

        $this->beforeSaveElement($elementData);

        $values = Shopware()->Events()->filter(
            'Shopware_Controllers_Backend_Config_Before_Save_Config_Element',
            $values,
            [
return $string;
    }

    /** * Parses an array into a Kint object structure. * * @param array &$var The input variable * @param Value $o The base object */
    private function parseArray(array &$var, Value $o): Value
    {
        $array = new Value();
        $array->transplant($o);
        $array->size = \count($var);

        if (isset($var[$this->marker])) {
            --$array->size;
            $array->hints[] = 'recursion';

            $this->applyPlugins($var$array, self::TRIGGER_RECURSION);

            return $array;
        }

        
return;
        }

        $x = new SimpleXMLElementValue();
        $x->transplant($o);

        $namespaces = \array_merge([null]$var->getDocNamespaces());

        // Attributes         $a = new Representation('Attributes');

        $base_obj = new Value();
        $base_obj->depth = $x->depth;

        if ($x->access_path) {
            $base_obj->access_path = '(string) '.$x->access_path;
        }

        // Attributes are strings. If we're too deep set the         // depth limit to enable parsing them, but no deeper.         if ($this->parser->getDepthLimit() && $this->parser->getDepthLimit() - 2 < $base_obj->depth) {
            $base_obj->depth = $this->parser->getDepthLimit() - 2;
        }

        
return;
        }

        $xml = \call_user_func([\get_class($this), 'xmlTo'.self::$parse_method]$var$o->access_path);

        if (empty($xml)) {
            return;
        }

        [$xml$access_path$name] = $xml;

        $base_obj = new Value();
        $base_obj->depth = $o->depth + 1;
        $base_obj->name = $name;
        $base_obj->access_path = $access_path;

        $r = new Representation('XML');
        $r->contents = $this->parser->parse($xml$base_obj);

        $o->addRepresentation($r, 0);
    }

    protected static function xmlToSimpleXML(string $var, ?string $parent_path): ?array
    {
throw new WriterException('Element is not valid', 0, $baseException);
        }

        /** @var Value|null $valueModel */
        $valueModel = $valueRepository->findOneBy(['shopId' => $shopId, 'element' => $element]);

        if ($valueModel === null) {
            if ($value === $parentValue || $value === null) {
                return;
            }

            $valueModel = new Value();
            $valueModel->setElement($element);
            $valueModel->setShopId($shopId);
            // serialize done by Doctrine             $valueModel->setValue($value);

            $this->modelManager->persist($valueModel);
            try {
                $this->modelManager->flush($valueModel);
            } catch (OptimisticLockException $e) {
                throw new WriterException('Failed writing to database', 0, $e);
            }

            
return;
        }

        $json = \json_decode($var, true);

        if (!$json) {
            return;
        }

        $json = (array) $json;

        $base_obj = new Value();
        $base_obj->depth = $o->depth;

        if ($o->access_path) {
            $base_obj->access_path = 'json_decode('.$o->access_path.', true)';
        }

        $r = new Representation('Json');
        $r->contents = $this->parser->parse($json$base_obj);

        if (!\in_array('depth_limit', $r->contents->hints, true)) {
            $r->contents = $r->contents->value->contents;
        }
$o->size = $var->length;
        if (0 === $o->size) {
            $o->replaceRepresentation(new Representation('Iterator'));
            $o->size = null;

            return;
        }

        // Depth limit         // Make empty iterator representation since we need it in DOMNode to point out depth limits         if ($this->parser->getDepthLimit() && $o->depth + 1 >= $this->parser->getDepthLimit()) {
            $b = new Value();
            $b->name = $o->classname.' Iterator Contents';
            $b->access_path = 'iterator_to_array('.$o->access_path.')';
            $b->depth = $o->depth + 1;
            $b->hints[] = 'depth_limit';

            $r = new Representation('Iterator');
            $r->contents = [$b];
            $o->replaceRepresentation($r, 0);

            return;
        }

        
$options = ['allowed_classes' => self::$allowed_classes];

        if (!self::$safe_mode || !\in_array($trimmed[0]['C', 'O', 'a'], true)) {
            // Suppress warnings on unserializeable variable             $data = @\unserialize($trimmed$options);

            if (false === $data && 'b:0;' !== \substr($trimmed, 0, 4)) {
                return;
            }
        }

        $base_obj = new Value();
        $base_obj->depth = $o->depth + 1;
        $base_obj->name = 'unserialize('.$o->name.')';

        if ($o->access_path) {
            $base_obj->access_path = 'unserialize('.$o->access_path;
            if (true === self::$allowed_classes) {
                $base_obj->access_path .= ')';
            } else {
                $base_obj->access_path .= ', '.\var_export($options, true).')';
            }
        }

        
Home | Imprint | This part of the site doesn't use cookies.