getTypeFromCustomFieldType example

private function getCustomFieldsMapping(Context $context): array
    {
        $fieldMapping = $this->getCustomFieldTypes($context);
        $mapping = [
            'type' => 'object',
            'dynamic' => true,
            'properties' => [],
        ];

        foreach ($fieldMapping as $name => $type) {
            /** @var array<mixed> $esType */
            $esType = CustomFieldUpdater::getTypeFromCustomFieldType($type);

            $mapping['properties'][$name] = $esType;
        }

        return $mapping;
    }

    /** * @param array<string, mixed> $customFields * * @return array<string, mixed> */
$customFieldUpdater->onNewCustomFieldCreated($containerEvent);
    }

    /** * @dataProvider providerMapping * * @param array<mixed> $mapping */
    public function testMapping(string $type, array $mapping): void
    {
        static::assertSame($mapping, CustomFieldUpdater::getTypeFromCustomFieldType($type));
    }

    /** * @return iterable<string, array{0: string, 1: array<mixed>}> */
    public static function providerMapping(): iterable
    {
        yield 'int' => [
            CustomFieldTypes::INT,
            [
                'type' => 'long',
            ],
$newCreatedFields = [];

        foreach ($event->getWriteResults() as $writeResult) {
            $existence = $writeResult->getExistence();

            if ($existence && $existence->exists()) {
                continue;
            }

            /** @var array<mixed> $esType */
            $esType = self::getTypeFromCustomFieldType($writeResult->getProperty('type'));

            $newCreatedFields[(string) $writeResult->getProperty('name')] = $esType;
        }

        if (\count($newCreatedFields) === 0) {
            return;
        }

        $this->createNewFieldsInIndices($newCreatedFields);
    }

    
private function getCustomFieldsMapping(Context $context): array
    {
        $fieldMapping = $this->getCustomFieldTypes($context);
        $mapping = [
            'type' => 'object',
            'dynamic' => true,
            'properties' => [],
        ];

        foreach ($fieldMapping as $name => $type) {
            /** @var array<mixed> $esType */
            $esType = CustomFieldUpdater::getTypeFromCustomFieldType($type);

            $mapping['properties'][$name] = $esType;
        }

        return $mapping;
    }

    /** * @param array<mixed> $customFields * * @return array<mixed> */
Home | Imprint | This part of the site doesn't use cookies.