Skip to content

Instantly share code, notes, and snippets.

@ohvitorino
Last active May 19, 2017 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohvitorino/bdc020038b38ce047787dffd06911d25 to your computer and use it in GitHub Desktop.
Save ohvitorino/bdc020038b38ce047787dffd06911d25 to your computer and use it in GitHub Desktop.
Generator for entities
<?php
namespace ProductsBundle\Command;
final class CreateProduct extends ProductDataTransferObject
{
}
<?php
namespace ProductsBundle\Command;
use ProductsBundle\Entity\Product;
final class CreateProductHandler
{
public function handle(CreateProduct $createProduct): void
{
}
}
<?php
namespace ProductsBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table
*/
final class Product
{
/**
* @var int
*
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var Collection
*
* @ORM\OneToMany(
* targetEntity="ProductsBundle\Entity\ProductTranslation",
* mappedBy="product",
* cascade={"all"},
* orphanRemoval=true
* )
*/
private $translations;
public function __construct()
{
$this->translations = new ArrayCollection();
}
public function getId(): int
{
return $this->id;
}
public function getTranslations(): Collection
{
return $this->translations;
}
}
<?php
namespace ProductsBundle\Command;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use ProductsBundle\Entity\Product;
class ProductDataTransferObject
{
/**
* @var Collection
*/
public $translations;
public function __construct()
{
$this->translations = new ArrayCollection();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment