hydrateFields example

if (isset($row[$root . '.visibleOnProductDetailPage'])) {
            $entity->visibleOnProductDetailPage = (bool) $row[$root . '.visibleOnProductDetailPage'];
        }
        if (isset($row[$root . '.createdAt'])) {
            $entity->createdAt = new \DateTimeImmutable($row[$root . '.createdAt']);
        }
        if (isset($row[$root . '.updatedAt'])) {
            $entity->updatedAt = new \DateTimeImmutable($row[$root . '.updatedAt']);
        }

        $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
        $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());
        $this->customFields($definition$row$root$entity$definition->getField('customFields')$context);

        return $entity;
    }
}

        if (isset($row[$root . '.createdAt'])) {
            $entity->createdAt = new \DateTimeImmutable($row[$root . '.createdAt']);
        }
        if (isset($row[$root . '.updatedAt'])) {
            $entity->updatedAt = new \DateTimeImmutable($row[$root . '.updatedAt']);
        }
        $entity->product = $this->manyToOne($row$root$definition->getField('product')$context);
        $entity->productStream = $this->manyToOne($row$root$definition->getField('productStream')$context);

        $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
        $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());

        return $entity;
    }
}


        if (isset($row[$root . '.customEntityTypeId'])) {
            $entity->customEntityTypeId = Uuid::fromBytesToHex($row[$root . '.customEntityTypeId']);
        }

        $entity->media = $this->manyToOne($row$root$definition->getField('media')$context);
        $entity->cmsPage = $this->manyToOne($row$root$definition->getField('cmsPage')$context);
        $entity->productStream = $this->manyToOne($row$root$definition->getField('productStream')$context);

        $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
        $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());
        $this->customFields($definition$row$root$entity$definition->getField('customFields')$context);
        $this->manyToMany($row$root$entity$definition->getField('products'));
        $this->manyToMany($row$root$entity$definition->getField('nestedProducts'));
        $this->manyToMany($row$root$entity$definition->getField('tags'));

        return $entity;
    }
}
if (\array_key_exists($root . '.fields', $row)) {
            $entity->fields = $definition->decode('fields', self::value($row$root, 'fields'));
        }
        if (isset($row[$root . '.createdAt'])) {
            $entity->createdAt = new \DateTimeImmutable($row[$root . '.createdAt']);
        }
        if (isset($row[$root . '.updatedAt'])) {
            $entity->updatedAt = new \DateTimeImmutable($row[$root . '.updatedAt']);
        }

        $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
        $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());

        return $entity;
    }
}
if (isset($row[$root . '.createdAt'])) {
            $entity->createdAt = new \DateTimeImmutable($row[$root . '.createdAt']);
        }
        if (isset($row[$root . '.updatedAt'])) {
            $entity->updatedAt = new \DateTimeImmutable($row[$root . '.updatedAt']);
        }
        $entity->product = $this->manyToOne($row$root$definition->getField('product')$context);
        $entity->media = $this->manyToOne($row$root$definition->getField('media')$context);
        $entity->option = $this->manyToOne($row$root$definition->getField('option')$context);

        $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
        $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());
        $this->customFields($definition$row$root$entity$definition->getField('customFields')$context);

        return $entity;
    }
}

        if (isset($row[$root . '.createdAt'])) {
            $entity->createdAt = new \DateTimeImmutable($row[$root . '.createdAt']);
        }
        if (isset($row[$root . '.updatedAt'])) {
            $entity->updatedAt = new \DateTimeImmutable($row[$root . '.updatedAt']);
        }
        $entity->product = $this->manyToOne($row$root$definition->getField('product')$context);
        $entity->crossSelling = $this->manyToOne($row$root$definition->getField('crossSelling')$context);

        $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
        $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());

        return $entity;
    }
}
$entity->customFields = $definition->decode('customFields', self::value($row$root, 'customFields'));
        }
        if (isset($row[$root . '.createdAt'])) {
            $entity->createdAt = new \DateTimeImmutable($row[$root . '.createdAt']);
        }
        if (isset($row[$root . '.updatedAt'])) {
            $entity->updatedAt = new \DateTimeImmutable($row[$root . '.updatedAt']);
        }
        $entity->productStream = $this->manyToOne($row$root$definition->getField('productStream')$context);

        $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
        $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());
        $this->customFields($definition$row$root$entity$definition->getField('customFields')$context);

        return $entity;
    }
}

        if (isset($row[$root . '.createdAt'])) {
            $entity->createdAt = new \DateTimeImmutable($row[$root . '.createdAt']);
        }
        if (isset($row[$root . '.updatedAt'])) {
            $entity->updatedAt = new \DateTimeImmutable($row[$root . '.updatedAt']);
        }
        $entity->searchConfig = $this->manyToOne($row$root$definition->getField('searchConfig')$context);
        $entity->customField = $this->manyToOne($row$root$definition->getField('customField')$context);

        $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
        $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());

        return $entity;
    }
}

        if (isset($row[$root . '.updatedAt'])) {
            $entity->updatedAt = new \DateTimeImmutable($row[$root . '.updatedAt']);
        }
        $entity->productStream = $this->manyToOne($row$root$definition->getField('productStream')$context);
        $entity->storefrontSalesChannel = $this->manyToOne($row$root$definition->getField('storefrontSalesChannel')$context);
        $entity->salesChannel = $this->manyToOne($row$root$definition->getField('salesChannel')$context);
        $entity->salesChannelDomain = $this->manyToOne($row$root$definition->getField('salesChannelDomain')$context);
        $entity->currency = $this->manyToOne($row$root$definition->getField('currency')$context);

        $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
        $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());

        return $entity;
    }
}
$entity->createdAt = new \DateTimeImmutable($row[$root . '.createdAt']);
        }
        if (isset($row[$root . '.updatedAt'])) {
            $entity->updatedAt = new \DateTimeImmutable($row[$root . '.updatedAt']);
        }
        $entity->product = $this->manyToOne($row$root$definition->getField('product')$context);
        $entity->customer = $this->manyToOne($row$root$definition->getField('customer')$context);
        $entity->salesChannel = $this->manyToOne($row$root$definition->getField('salesChannel')$context);
        $entity->language = $this->manyToOne($row$root$definition->getField('language')$context);

        $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
        $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());
        $this->customFields($definition$row$root$entity$definition->getField('customFields')$context);

        return $entity;
    }
}
$entity->excludedTerms = $definition->decode('excludedTerms', self::value($row$root, 'excludedTerms'));
        }
        if (isset($row[$root . '.createdAt'])) {
            $entity->createdAt = new \DateTimeImmutable($row[$root . '.createdAt']);
        }
        if (isset($row[$root . '.updatedAt'])) {
            $entity->updatedAt = new \DateTimeImmutable($row[$root . '.updatedAt']);
        }
        $entity->language = $this->manyToOne($row$root$definition->getField('language')$context);

        $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
        $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());

        return $entity;
    }
}
return $mapped;
    }

    /** * Allows simple overwrite for specialized entity hydrators * * @param array<mixed> $row */
    protected function assign(EntityDefinition $definition, Entity $entity, string $root, array $row, Context $context): Entity
    {
        $entity = $this->hydrateFields($definition$entity$root$row$context$definition->getFields());

        return $entity;
    }

    /** * @param array<mixed> $row * @param iterable<Field> $fields */
    protected function hydrateFields(EntityDefinition $definition, Entity $entity, string $root, array $row, Context $context, iterable $fields): Entity
    {
        /** @var ArrayStruct<string, mixed> $foreignKeys */
        

        if (isset($row[$root . '.createdAt'])) {
            $entity->createdAt = new \DateTimeImmutable($row[$root . '.createdAt']);
        }
        if (isset($row[$root . '.updatedAt'])) {
            $entity->updatedAt = new \DateTimeImmutable($row[$root . '.updatedAt']);
        }
        $entity->salesChannel = $this->manyToOne($row$root$definition->getField('salesChannel')$context);
        $entity->product = $this->manyToOne($row$root$definition->getField('product')$context);

        $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
        $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());

        return $entity;
    }
}

        if (isset($row[$root . '.createdAt'])) {
            $entity->createdAt = new \DateTimeImmutable($row[$root . '.createdAt']);
        }
        if (isset($row[$root . '.updatedAt'])) {
            $entity->updatedAt = new \DateTimeImmutable($row[$root . '.updatedAt']);
        }
        $entity->media = $this->manyToOne($row$root$definition->getField('media')$context);
        $entity->group = $this->manyToOne($row$root$definition->getField('group')$context);

        $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
        $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());
        $this->customFields($definition$row$root$entity$definition->getField('customFields')$context);
        $this->manyToMany($row$root$entity$definition->getField('productProperties'));
        $this->manyToMany($row$root$entity$definition->getField('productOptions'));

        return $entity;
    }
}

        $entity->deliveryTime = $this->manyToOne($row$root$definition->getField('deliveryTime')$context);
        $entity->tax = $this->manyToOne($row$root$definition->getField('tax')$context);
        $entity->manufacturer = $this->manyToOne($row$root$definition->getField('manufacturer')$context);
        $entity->unit = $this->manyToOne($row$root$definition->getField('unit')$context);
        $entity->cover = $this->manyToOne($row$root$definition->getField('cover')$context);
        $entity->featureSet = $this->manyToOne($row$root$definition->getField('featureSet')$context);
        $entity->cmsPage = $this->manyToOne($row$root$definition->getField('cmsPage')$context);
        $entity->canonicalProduct = $this->manyToOne($row$root$definition->getField('canonicalProduct')$context);

        $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
        $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());
        $this->customFields($definition$row$root$entity$definition->getField('customFields')$context);
        $this->manyToMany($row$root$entity$definition->getField('options'));
        $this->manyToMany($row$root$entity$definition->getField('properties'));
        $this->manyToMany($row$root$entity$definition->getField('categories'));
        $this->manyToMany($row$root$entity$definition->getField('streams'));
        $this->manyToMany($row$root$entity$definition->getField('categoriesRo'));
        $this->manyToMany($row$root$entity$definition->getField('tags'));
        $this->manyToMany($row$root$entity$definition->getField('customFieldSets'));

        return $entity;
    }
}
Home | Imprint | This part of the site doesn't use cookies.