src/Core/Content/Product/Aggregate/ProductMedia/ProductMediaHydrator.php line 42

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Product\Aggregate\ProductMedia;
  3. use Shopware\Core\Framework\Context;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Dbal\EntityHydrator;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Entity;
  6. use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
  7. use Shopware\Core\Framework\Log\Package;
  8. use Shopware\Core\Framework\Uuid\Uuid;
  9. #[Package('inventory')]
  10. class ProductMediaHydrator extends EntityHydrator
  11. {
  12.     protected function assign(EntityDefinition $definitionEntity $entitystring $root, array $rowContext $context): Entity
  13.     {
  14.         if (isset($row[$root '.id'])) {
  15.             $entity->id Uuid::fromBytesToHex($row[$root '.id']);
  16.         }
  17.         if (isset($row[$root '.versionId'])) {
  18.             $entity->versionId Uuid::fromBytesToHex($row[$root '.versionId']);
  19.         }
  20.         if (isset($row[$root '.productId'])) {
  21.             $entity->productId Uuid::fromBytesToHex($row[$root '.productId']);
  22.         }
  23.         if (isset($row[$root '.mediaId'])) {
  24.             $entity->mediaId Uuid::fromBytesToHex($row[$root '.mediaId']);
  25.         }
  26.         if (isset($row[$root '.position'])) {
  27.             $entity->position = (int) $row[$root '.position'];
  28.         }
  29.         if (\array_key_exists($root '.customFields'$row)) {
  30.             $entity->customFields $definition->decode('customFields'self::value($row$root'customFields'));
  31.         }
  32.         if (isset($row[$root '.createdAt'])) {
  33.             $entity->createdAt = new \DateTimeImmutable($row[$root '.createdAt']);
  34.         }
  35.         if (isset($row[$root '.updatedAt'])) {
  36.             $entity->updatedAt = new \DateTimeImmutable($row[$root '.updatedAt']);
  37.         }
  38.         $entity->product $this->manyToOne($row$root$definition->getField('product'), $context);
  39.         $entity->media $this->manyToOne($row$root$definition->getField('media'), $context);
  40.         $this->translate($definition$entity$row$root$context$definition->getTranslatedFields());
  41.         $this->hydrateFields($definition$entity$root$row$context$definition->getExtensionFields());
  42.         $this->customFields($definition$row$root$entity$definition->getField('customFields'), $context);
  43.         return $entity;
  44.     }
  45. }