getPrimaryKeys example


    }

    /** * @return array<mixed> */
    private function getMergeableTranslationPayload(EntityWriteResult $translationResult): array
    {
        // use PKs from definition because versionIds are removed from the writeResult         $pks = $this->definitionRegistry
            ->getByEntityName($translationResult->getEntityName())
            ->getPrimaryKeys()
            ->getKeys();

        return array_diff_key(
            $translationResult->getPayload(),
            array_flip($pks)
        );
    }
}

    private function getDummyPrimaryKeys(array $payload): array
    {
        if (!$this->definition instanceof EntityDefinition) {
            return [];
        }

        $primaryKeys = [];

        /** @var Field $field */
        foreach ($this->definition->getPrimaryKeys() as $field) {
            $primaryKeys[$field->getPropertyName()] = $payload[$field->getPropertyName()] ?? Uuid::randomHex();
        }

        return $primaryKeys;
    }

    private function getDummyEntityName(): string
    {
        if (!$this->definition instanceof EntityDefinition) {
            return 'mock';
        }

        
$ids = $iterator->fetch();

        if (empty($ids)) {
            return null;
        }

        return new MediaIndexingMessage(array_values($ids)$iterator->getOffset());
    }

    public function update(EntityWrittenContainerEvent $event): ?EntityIndexingMessage
    {
        $updates = $event->getPrimaryKeys(MediaFolderDefinition::ENTITY_NAME);
        $mediaFolderEvent = $event->getEventByEntityName(MediaFolderDefinition::ENTITY_NAME);

        if (empty($updates) || !$mediaFolderEvent) {
            return null;
        }

        $idsWithChangedParentIds = [];
        foreach ($mediaFolderEvent->getWriteResults() as $result) {
            $payload = $result->getPayload();
            if (\array_key_exists('parentId', $payload)) {
                $idsWithChangedParentIds[] = $payload['id'];
            }
if (!$updatedBy) {
            return $record;
        }

        $updateByField = $updatedBy->getMappedKey();

        if (empty($updateByField) || $definition->getField($updateByField) instanceof IdField) {
            return $record;
        }

        $idFields = $definition->getPrimaryKeys()->filter(fn (Field $field) => $field instanceof IdField);
        $idField = $idFields->first();

        if ($idFields->count() !== 1 || !$idField) {
            return $record;
        }

        $primaryKeyProperty = $idField->getPropertyName();

        $updateByFieldPath = explode('.', $updateByField);
        $record = \is_array($record) ? $record : iterator_to_array($record);
        $updateByValue = $this->getValueFromPath($record$updateByFieldPath);

        

        return new $class();
    }

    /** * @param array<mixed> $row * * @return array<mixed> */
    final public static function buildUniqueIdentifier(EntityDefinition $definition, array $row, string $root): array
    {
        $primaryKeyFields = $definition->getPrimaryKeys();
        $primaryKey = [];

        foreach ($primaryKeyFields as $field) {
            if ($field instanceof VersionField || $field instanceof ReferenceVersionField) {
                continue;
            }
            $accessor = $root . '.' . $field->getPropertyName();

            $primaryKey[$field->getPropertyName()] = $field->getSerializer()->decode($field$row[$accessor]);
        }

        


        $ids = [];

        foreach ($this->getCommands() as $entityWriteResult) {
            $definition = $entityWriteResult->getDefinition();

            if ($definition->getEntityName() !== $entity) {
                continue;
            }

            $primaryKeys = $definition->getPrimaryKeys()->filter(static fn (Field $field) => !$field instanceof VersionField
                && !$field instanceof ReferenceVersionField
                && $field instanceof StorageAware);

            $ids[] = $this->getCommandPrimaryKey($entityWriteResult$primaryKeys);
        }

        return $this->ids[$entity] = $ids;
    }

    public function filled(): bool
    {
        


    /** * @param array<mixed> $data * * @return array<mixed> */
    public function normalizeSingle(EntityDefinition $definition, array $data, WriteParameterBag $parameters): array
    {
        $done = [];

        foreach ($definition->getPrimaryKeys() as $pkField) {
            $data = $pkField->getSerializer()->normalize($pkField$data$parameters);
            $done[$pkField->getPropertyName()] = true;
        }

        $normalizedTranslations = false;
        foreach ($data as $property => $_) {
            if (\array_key_exists($property$done)) {
                continue;
            }

            $field = $definition->getFields()->get($property);
            
$ids = $iterator->fetch();

        if (empty($ids)) {
            return null;
        }

        return new FlowIndexingMessage(array_values($ids)$iterator->getOffset());
    }

    public function update(EntityWrittenContainerEvent $event): ?EntityIndexingMessage
    {
        $updates = $event->getPrimaryKeys(FlowDefinition::ENTITY_NAME);

        if (empty($updates)) {
            return null;
        }

        $this->handle(new FlowIndexingMessage(array_values($updates), null, $event->getContext()));

        return null;
    }

    public function handle(EntityIndexingMessage $message): void
    {


    /** * @return FkField[] */
    private function getFkFields(EntityTranslationDefinition $definition): array
    {
        $rootEntity = $definition->getParentDefinition();
        $idStorageName = $rootEntity->getEntityName() . '_id';
        $versionIdStorageName = $rootEntity->getEntityName() . '_version_id';

        $pks = $definition->getPrimaryKeys();
        $idField = $pks->getByStorageName($idStorageName);
        if (!$idField || !$idField instanceof FkField) {
            throw new \RuntimeException(sprintf('`%s` primary key should have column `%s`', $definition->getEntityName()$idStorageName));
        }
        $fields = [
            'id' => $idField,
        ];

        $versionIdField = $pks->getByStorageName($versionIdStorageName);
        if ($versionIdField && $versionIdField instanceof FkField) {
            $fields['version'] = $versionIdField;
        }
$this->getContainer()->get('product.repository')
            ->update([['id' => $ids->get('p1'), 'name' => 'test']]$versionContext);

        // now ensure that we get a validate event for the merge request         $called = false;

        $this->addEventListener(
            $this->getContainer()->get('event_dispatcher'),
            PreWriteValidationEvent::class,
            function DPreWriteValidationEvent $event) use (&$called): void {
                // we also get a validation event for the version tables                 if (!$event->getPrimaryKeys('product')) {
                    return;
                }

                $called = true;
                // some validators depend on that to disable insert/update validation for merge requests                 static::assertTrue($event->getWriteContext()->hasState(VersionManager::MERGE_SCOPE));
            }
        );

        $this->getContainer()->get('product.repository')->merge($versionId$context);

        
$this->refreshIndices();
        }

        /** @var array<string, string> $indices */
        $indices = $this->connection->fetchAllKeyValue('SELECT `alias`, `index` FROM admin_elasticsearch_index_task');

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

        foreach ($this->indexer as $indexer) {
            $ids = $event->getPrimaryKeys($indexer->getEntity());

            if (empty($ids)) {
                continue;
            }
            $documents = $indexer->fetch($ids);

            $this->push($indexer$indices$documents$ids);
        }
    }

    /** * @return AbstractAdminIndexer[] */
$ids = $iterator->fetch();

        if (empty($ids)) {
            return null;
        }

        return new NewsletterRecipientIndexingMessage(array_values($ids)$iterator->getOffset());
    }

    public function update(EntityWrittenContainerEvent $event): ?EntityIndexingMessage
    {
        $updates = $event->getPrimaryKeys(NewsletterRecipientDefinition::ENTITY_NAME);

        if (empty($updates)) {
            return null;
        }

        return new NewsletterRecipientIndexingMessage(array_values($updates), null, $event->getContext());
    }

    public function handle(EntityIndexingMessage $message): void
    {
        $ids = $message->getData();
        
EntityDefinitionQueryHelper::escape($root->getEntityName())
        );

        $this->queryHelper->resolveField($association$root$root->getEntityName()$query$context);

        $alias = $root->getEntityName() . '.' . $association->getPropertyName();

        if ($association instanceof ManyToManyAssociationField) {
            $alias .= '.mapping';
        }

        $primaryKeys = $association->getReferenceDefinition()->getPrimaryKeys()->filter(function DField $field) {
            if ($field instanceof ReferenceVersionField || $field instanceof VersionField) {
                return null;
            }

            return $field;
        });

        foreach ($primaryKeys as $field) {
            if (!$field instanceof StorageAware) {
                continue;
            }
            
$updatedData = $this->updateMediaInConfiguration($theme$configuration$context);

        $themeData = array_merge($themeData$updatedData);

        if (!empty($configuration->getConfigInheritance())) {
            $themeData = $this->addParentTheme($configuration$themeData$context);
        }

        $writtenEvent = $this->themeRepository->upsert([$themeData]$context);

        if (empty($themeData['id'])) {
            $themeData['id'] = current($writtenEvent->getPrimaryKeys(ThemeDefinition::ENTITY_NAME));
        }

        $this->themeRepository->upsert([$themeData]$context);

        if (!empty($themeData['toDeleteMedia'])) {
            $this->themeMediaRepository->delete($themeData['toDeleteMedia']$context);
        }

        $parentThemes = $this->getParentThemes($configuration$themeData['id']);
        $parentCriteria = new Criteria();
        $parentCriteria->addFilter(new EqualsFilter('childId', $themeData['id']));
        
$ids = $iterator->fetch();

        if (empty($ids)) {
            return null;
        }

        return new LandingPageIndexingMessage(array_values($ids)$iterator->getOffset());
    }

    public function update(EntityWrittenContainerEvent $event): ?EntityIndexingMessage
    {
        $updates = $event->getPrimaryKeys(LandingPageDefinition::ENTITY_NAME);

        if (empty($updates)) {
            return null;
        }

        return new LandingPageIndexingMessage(array_values($updates), null, $event->getContext());
    }

    public function handle(EntityIndexingMessage $message): void
    {
        $ids = $message->getData();
        
Home | Imprint | This part of the site doesn't use cookies.