getPosition example

$customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $multiEntitySelectField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(SingleEntitySelectField::class$multiEntitySelectField);
        static::assertEquals('test_multi_entity_select_field', $multiEntitySelectField->getName());
        static::assertEquals([
            'en-GB' => 'Test multi-entity-select field',
        ]$multiEntitySelectField->getLabel());
        static::assertEquals([]$multiEntitySelectField->getHelpText());
        static::assertEquals(1, $multiEntitySelectField->getPosition());
        static::assertEquals(['en-GB' => 'Choose an entity...']$multiEntitySelectField->getPlaceholder());
        static::assertFalse($multiEntitySelectField->getRequired());
        static::assertEquals('product', $multiEntitySelectField->getEntity());
    }

    public function testToEntityArray(): void
    {
        $multiEntitySelectField = $this->importCustomField(__DIR__ . '/_fixtures/multi-entity-select-field.xml');

        static::assertEquals('test_multi_entity_select_field', $multiEntitySelectField->getName());
        static::assertEquals('entity', $multiEntitySelectField->getType());
        
$stream->getNext();
            } else {
                throw SyntaxErrorException::unexpectedToken('operator', $next);
            }
        }

        $stream->skipWhitespace();
        $value = $stream->getNext();

        if ($value->isNumber()) {
            // if the value is a number, it's casted into a string             $value = new Token(Token::TYPE_STRING, (string) $value->getValue()$value->getPosition());
        }

        if (!($value->isIdentifier() || $value->isString())) {
            throw SyntaxErrorException::unexpectedToken('string or identifier', $value);
        }

        $stream->skipWhitespace();
        $next = $stream->getNext();

        if (!$next->isDelimiter([']'])) {
            throw SyntaxErrorException::unexpectedToken('"]"', $next);
        }
->addAssociation('options.group')
            ->addAssociation('properties.group')
            ->addAssociation('mainCategories.category')
            ->addAssociation('media');

        $this->eventDispatcher->dispatch(new ProductPageCriteriaEvent($productId$criteria$context));

        $result = $this->productDetailRoute->load($productId$request$context$criteria);
        $product = $result->getProduct();

        if ($product->getMedia()) {
            $product->getMedia()->sort(fn (ProductMediaEntity $a, ProductMediaEntity $b) => $a->getPosition() <=> $b->getPosition());
        }

        if ($product->getMedia() && $product->getCover()) {
            $product->setMedia(new ProductMediaCollection(array_merge(
                [$product->getCover()->getId() => $product->getCover()],
                $product->getMedia()->getElements()
            )));
        }

        if ($category = $product->getSeoCategory()) {
            $request->request->set('navigationId', $category->getId());
        }
return $this->createField($options);
    }

    public function getMaxPositionValue()
    {
        if ($this->maxFieldPositionValue === null) {
            $this->maxFieldPositionValue = 0;

            $positions = array_map(
                function D$field) {
                    return $field->getPosition();
                },
                $this->getFields()->toArray()
            );

            $this->maxFieldPositionValue = !empty($positions) ? max($positions) : 0;
        }

        return $this->maxFieldPositionValue;
    }
}
$customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $mediaSelectionField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(MediaSelectionField::class$mediaSelectionField);
        static::assertEquals('test_media_selection_field', $mediaSelectionField->getName());
        static::assertEquals([
            'en-GB' => 'Test media-selection field',
        ]$mediaSelectionField->getLabel());
        static::assertEquals([]$mediaSelectionField->getHelpText());
        static::assertEquals(1, $mediaSelectionField->getPosition());
        static::assertFalse($mediaSelectionField->getRequired());
    }

    public function testToEntityArray(): void
    {
        $mediaSelectionField = $this->importCustomField(__DIR__ . '/_fixtures/media-selection-field.xml');

        static::assertEquals('test_media_selection_field', $mediaSelectionField->getName());
        static::assertEquals('text', $mediaSelectionField->getType());
        static::assertTrue($mediaSelectionField->isActive());
        static::assertEquals([
            
$customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $dateTimeField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(DateTimeField::class$dateTimeField);
        static::assertEquals('test_datetime_field', $dateTimeField->getName());
        static::assertEquals([
            'en-GB' => 'Test datetime field',
        ]$dateTimeField->getLabel());
        static::assertEquals([]$dateTimeField->getHelpText());
        static::assertEquals(1, $dateTimeField->getPosition());
        static::assertFalse($dateTimeField->getRequired());
    }

    public function testToEntityArray(): void
    {
        $dateTimeField = $this->importCustomField(__DIR__ . '/_fixtures/date-time-field.xml');

        static::assertEquals('test_datetime_field', $dateTimeField->getName());
        static::assertEquals('datetime', $dateTimeField->getType());
        static::assertTrue($dateTimeField->isActive());
        static::assertEquals([
            
public function __construct(string $serviceId, string $type, \ReflectionParameter $parameter)
    {
        $acceptedType = $parameter->getType();
        $acceptedType = $acceptedType instanceof \ReflectionNamedType ? $acceptedType->getName() : (string) $acceptedType;
        $this->code = $type;

        $function = $parameter->getDeclaringFunction();
        $functionName = $function instanceof \ReflectionMethod
            ? sprintf('%s::%s', $function->getDeclaringClass()->getName()$function->getName())
            : $function->getName();

        parent::__construct(sprintf('Invalid definition for service "%s": argument %d of "%s()" accepts "%s", "%s" passed.', $serviceId, 1 + $parameter->getPosition()$functionName$acceptedType$type));
    }
}


        $this->sortOptionsAlphanumeric($options);
    }

    /** * @param array<Option> $options */
    private function sortOptionsByPosition(array &$options): void
    {
        usort($optionsfunction DOption $a, Option $b): int {
            return $a->getPosition() <=> $b->getPosition();
        });
    }

    /** * @param array<Option> $options */
    private function sortOptionsNumericalValue(array &$options): void
    {
        usort($optionsfunction DOption $a, Option $b): int {
            $aValue = (float) str_replace(',', '.', $a->getName());
            $bValue = (float) str_replace(',', '.', $b->getName());

            
/** * Helper function which creates a variant image for the passed product image. * * @return Image */
    public function createVariantImage(Image $articleImage, Detail $variant)
    {
        $variantImage = new Image();
        $variantImage->setParent($articleImage);
        $variantImage->setArticleDetail($variant);
        $variantImage->setPosition($articleImage->getPosition());
        $variantImage->setMain($articleImage->getMain());
        $variantImage->setExtension($articleImage->getExtension());

        return $variantImage;
    }

    /** * @param Collection|array $options * * @return Mapping */
    
static::assertCount(1, $customFieldSet->getFields());

        $textAreaField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(TextAreaField::class$textAreaField);
        static::assertEquals('test_text_area_field', $textAreaField->getName());
        static::assertEquals([
            'en-GB' => 'Test text-area field',
        ]$textAreaField->getLabel());
        static::assertEquals([]$textAreaField->getHelpText());
        static::assertEquals(['en-GB' => 'Enter a text...']$textAreaField->getPlaceholder());
        static::assertEquals(1, $textAreaField->getPosition());
        static::assertFalse($textAreaField->getRequired());
    }

    public function testToEntityArray(): void
    {
        $textAreaField = $this->importCustomField(__DIR__ . '/_fixtures/text-area-field.xml');

        static::assertEquals('test_text_area_field', $textAreaField->getName());
        static::assertEquals('html', $textAreaField->getType());
        static::assertTrue($textAreaField->isActive());
        static::assertEquals([
            
$data = Unicode::convertToUtf8($data$js_asset['attributes']['charset']);
    }
    // Remove comments, whitespace, and optional braces.     try {
      $ast = Peast::latest($data)->parse();
      $renderer = new Renderer();
      $renderer->setFormatter(new CompactFormatter());
      return $renderer->render($ast);
    }
    catch (\Exception $exception) {
      if ($exception instanceof PeastSyntaxException) {
        $position = $exception->getPosition();
        Error::logException($this->logger, $exception, 'Syntax error: @message, File: @asset_file, Line: @asset_line, Column: @asset_column, Index: @asset_index', [
          '@asset_file' => $js_asset['data'],
          '@asset_line' => $position->getLine(),
          '@asset_column' => $position->getColumn(),
          '@asset_index' => $position->getIndex(),
        ]);
      }
      else {
        Error::logException($this->logger, $exception);
      }
      return $data;
    }
$this->patterns = $patterns;
    }

    public function handle(Reader $reader, TokenStream $stream): bool
    {
        $match = $reader->findPattern($this->patterns->getNumberPattern());

        if (!$match) {
            return false;
        }

        $stream->push(new Token(Token::TYPE_NUMBER, $match[0]$reader->getPosition()));
        $reader->moveForward(\strlen($match[0]));

        return true;
    }
}
protected function parseJSXChild()
    {
        if ($node = $this->parseJSXText()) {
            return $node;
        } elseif ($node = $this->parseJSXFragment()) {
            return $node;
        } elseif($node = $this->parseJSXElement()) {
            return $node;
        } elseif ($startToken = $this->scanner->consume("{")) {
            $spread = $this->scanner->consume("...");
            $exp = $this->parseAssignmentExpression();
            $midPos = $this->scanner->getPosition();
            if (($spread && !$exp) || !$this->scanner->consume("}")) {
                $this->error();
            }
            $node = $this->createJSXNode(
                $spread ? "JSXSpreadChild" : "JSXExpressionContainer",
                $startToken
            );
            if (!$exp) {
                $exp = $this->createJSXNode("JSXEmptyExpression", $midPos);
                $this->completeNode($exp$midPos);
            }
            
$falseCase = null;

                    if ($parent->getRuleId()) {
                        $generateFalseCase = $this->faker->boolean();

                        if ($generateFalseCase) {
                            $falseCase = $this->buildRandomSequence($parent, false);

                            $sequences->add($falseCase);

                            $parent->setPosition($parent->getPosition() + 1);
                        }
                    }

                    $sequence = $this->buildRandomSequence($parent);

                    if ($isRoot) {
                        $sequence->assign([
                            'parentId' => null,
                        ]);

                        $isRoot = false;
                    }
$customFieldSet = $manifest->getCustomFields()->getCustomFieldSets()[0];

        static::assertCount(1, $customFieldSet->getFields());

        $singleEntitySelectField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(SingleEntitySelectField::class$singleEntitySelectField);
        static::assertEquals('test_single_entity_select_field', $singleEntitySelectField->getName());
        static::assertEquals([
            'en-GB' => 'Test single-entity-select field',
        ]$singleEntitySelectField->getLabel());
        static::assertEquals([]$singleEntitySelectField->getHelpText());
        static::assertEquals(1, $singleEntitySelectField->getPosition());
        static::assertEquals(['en-GB' => 'Choose an entity...']$singleEntitySelectField->getPlaceholder());
        static::assertFalse($singleEntitySelectField->getRequired());
        static::assertEquals('product', $singleEntitySelectField->getEntity());
    }

    public function testToEntityArray(): void
    {
        $singleEntitySelectField = $this->importCustomField(__DIR__ . '/_fixtures/single-entity-select-field.xml');

        static::assertEquals('test_single_entity_select_field', $singleEntitySelectField->getName());
        static::assertEquals('entity', $singleEntitySelectField->getType());
        
Home | Imprint | This part of the site doesn't use cookies.