Skip to content

Commit

Permalink
[framework] FileUpload: set position for the new images only (#3381)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitek-rostislav committed Aug 29, 2024
1 parent 7b2c8e2 commit a4403d1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Component/FileUpload/EntityFileUploadInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function setFileAsUploaded(string $key, string $originalFilename): void;
public function setFileKeyAsUploaded(string $key): void;

/**
* @return int
* @return int|null
*/
public function getId();
}
2 changes: 1 addition & 1 deletion src/Component/FileUpload/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function preFlushEntity(EntityFileUploadInterface $entity)
$entity->setFileAsUploaded($key, $originalFilename);
}

if ($entity instanceof Image && $entity->getPosition() === Image::DEFAULT_IMAGE_POSITION) {
if ($entity instanceof Image && $entity->getId() === null) {
$entity->setPosition($this->getPositionForNewEntity($entity));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Component/Image/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Image extends AbstractTranslatableEntity implements EntityFileUploadInterf
public const int DEFAULT_IMAGE_POSITION = 0;

/**
* @var int
* @var int|null
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
Expand Down Expand Up @@ -226,7 +226,7 @@ public function getFilename(): string
}

/**
* @return int
* @return int|null
*/
public function getId()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Component/UploadedFile/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function getFilename(): string
}

/**
* @return int
* @return int|null
*/
public function getId()
{
Expand Down

0 comments on commit a4403d1

Please sign in to comment.