vendor/shopware/core/Content/Category/CategoryHydrator.php line 80

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Category;
  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('content')]
  10. class CategoryHydrator extends EntityHydrator
  11. {
  12.     protected function assign(EntityDefinition $definition, Entity $entity, string $root, array $row, Context $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 . '.parentId'])) {
  21.             $entity->parentId = Uuid::fromBytesToHex($row[$root . '.parentId']);
  22.         }
  23.         if (isset($row[$root . '.afterCategoryId'])) {
  24.             $entity->afterCategoryId = Uuid::fromBytesToHex($row[$root . '.afterCategoryId']);
  25.         }
  26.         if (isset($row[$root . '.mediaId'])) {
  27.             $entity->mediaId = Uuid::fromBytesToHex($row[$root . '.mediaId']);
  28.         }
  29.         if (isset($row[$root . '.displayNestedProducts'])) {
  30.             $entity->displayNestedProducts = (bool) $row[$root . '.displayNestedProducts'];
  31.         }
  32.         if (isset($row[$root . '.autoIncrement'])) {
  33.             $entity->autoIncrement = (int) $row[$root . '.autoIncrement'];
  34.         }
  35.         if (isset($row[$root . '.level'])) {
  36.             $entity->level = (int) $row[$root . '.level'];
  37.         }
  38.         if (\array_key_exists($root . '.path', $row)) {
  39.             $entity->path = $definition->decode('path', self::value($row, $root, 'path'));
  40.         }
  41.         if (isset($row[$root . '.childCount'])) {
  42.             $entity->childCount = (int) $row[$root . '.childCount'];
  43.         }
  44.         if (isset($row[$root . '.type'])) {
  45.             $entity->type = $row[$root . '.type'];
  46.         }
  47.         if (isset($row[$root . '.productAssignmentType'])) {
  48.             $entity->productAssignmentType = $row[$root . '.productAssignmentType'];
  49.         }
  50.         if (isset($row[$root . '.visible'])) {
  51.             $entity->visible = (bool) $row[$root . '.visible'];
  52.         }
  53.         if (isset($row[$root . '.active'])) {
  54.             $entity->active = (bool) $row[$root . '.active'];
  55.         }
  56.         if (isset($row[$root . '.cmsPageId'])) {
  57.             $entity->cmsPageId = Uuid::fromBytesToHex($row[$root . '.cmsPageId']);
  58.         }
  59.         if (isset($row[$root . '.productStreamId'])) {
  60.             $entity->productStreamId = Uuid::fromBytesToHex($row[$root . '.productStreamId']);
  61.         }
  62.         if (isset($row[$root . '.createdAt'])) {
  63.             $entity->createdAt = new \DateTimeImmutable($row[$root . '.createdAt']);
  64.         }
  65.         if (isset($row[$root . '.updatedAt'])) {
  66.             $entity->updatedAt = new \DateTimeImmutable($row[$root . '.updatedAt']);
  67.         }
  68.         if (isset($row[$root . '.customEntityTypeId'])) {
  69.             $entity->customEntityTypeId = Uuid::fromBytesToHex($row[$root . '.customEntityTypeId']);
  70.         }
  71.         $entity->media = $this->manyToOne($row, $root, $definition->getField('media'), $context);
  72.         $entity->cmsPage = $this->manyToOne($row, $root, $definition->getField('cmsPage'), $context);
  73.         $entity->productStream = $this->manyToOne($row, $root, $definition->getField('productStream'), $context);
  74.         $this->translate($definition, $entity, $row, $root, $context, $definition->getTranslatedFields());
  75.         $this->hydrateFields($definition, $entity, $root, $row, $context, $definition->getExtensionFields());
  76.         $this->customFields($definition, $row, $root, $entity, $definition->getField('customFields'), $context);
  77.         $this->manyToMany($row, $root, $entity, $definition->getField('products'));
  78.         $this->manyToMany($row, $root, $entity, $definition->getField('nestedProducts'));
  79.         $this->manyToMany($row, $root, $entity, $definition->getField('tags'));
  80.         return $entity;
  81.     }
  82. }