for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Zenstruck\Foundry\Tests\Fixtures\Entity\Cascade;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="variant_cascade")
* @ORM\HasLifecycleCallbacks
*/
class Variant
{
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
private $id;
* @ORM\Column(type="integer", nullable=true)
private $prePersistedId;
* @ORM\Column(type="string", length=255)
private $name;
* @ORM\ManyToOne(targetEntity=Product::class, inversedBy="variants")
private $product;
* @ORM\OneToOne(targetEntity=Image::class, cascade={"persist"})
private $image;
public function getId(): ?int
return $this->id;
}
public function getPrePersistedId(): ?int
return $this->prePersistedId;
public function setPrePersistedId(?int $prePersistedId): void
$this->prePersistedId = $prePersistedId;
public function getName(): ?string
return $this->name;
public function setName(?string $name): void
$this->name = $name;
public function getProduct(): ?Product
return $this->product;
public function setProduct(Product $product): void
$this->product = $product;
public function getImage(): ?Image
return $this->image;
public function setImage(Image $image): void
$this->image = $image;
* @ORM\PrePersist
public function generatePrePersist()
if (null !== $this->image) {
$this->image->setPrePersistedId($this->image->getId());