Skip to content

Commit

Permalink
Refactored entities through FormEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHAnderson committed Mar 2, 2024
1 parent 96007c7 commit c936383
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 159 deletions.
32 changes: 14 additions & 18 deletions tests/Assets/Entity/Test.php → tests/Assets/Entity/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,22 @@

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="doctrine_orm_module_test")
*/
class Test
#[ORM\Entity]
#[ORM\Table(name: 'doctrine_orm_module_auth')]
class Auth
{
/**
* @ORM\Id
* @ORM\Column(type="integer");
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected int $id;
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private int $id;

/** @ORM\Column(type="string", nullable=true) */
protected string $username;
#[ORM\Column(type: 'string', nullable: true)]
private string $username;

/** @ORM\Column(type="string", nullable=true) */
protected string $password;
#[ORM\Column(type: 'string', nullable: true)]
private string $password;

public function getId(): ?int
public function getId(): int|null
{
return $this->id;
}
Expand All @@ -35,7 +31,7 @@ public function setPassword(string $password): void
$this->password = (string) $password;
}

public function getPassword(): ?string
public function getPassword(): string|null
{
return $this->password;
}
Expand All @@ -45,7 +41,7 @@ public function setUsername(string $username): void
$this->username = (string) $username;
}

public function getUsername(): ?string
public function getUsername(): string|null
{
return $this->username;
}
Expand Down
22 changes: 9 additions & 13 deletions tests/Assets/Entity/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="doctrine_orm_module_category")
*/
#[ORM\Entity]
#[ORM\Table(name: 'doctrine_orm_module_category')]
class Category
{
/**
* @ORM\Id
* @ORM\Column(type="integer");
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected int $id;
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private int $id;

/** @ORM\Column(type="string", nullable=true) */
protected string $name;
#[ORM\Column(type: 'string', nullable: true)]
private string $name;

public function getId(): ?int
public function getId(): int|null
{
return $this->id;
}
Expand Down
27 changes: 12 additions & 15 deletions tests/Assets/Entity/City.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,23 @@

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="doctrine_orm_module_city")
*/
#[ORM\Entity]
#[ORM\Table(name: 'doctrine_orm_module_city')]
class City
{
/**
* @ORM\Id
* @ORM\Column(type="integer");
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected int $id;
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private int $id;

/** @ORM\Column(type="string", nullable=true) */
protected string $name;
#[ORM\Column(type: 'string', nullable: true)]
private string $name;

/** @ORM\OneToOne(targetEntity="Country") */
protected Country $country;
#[ORM\OneToOne(targetEntity: Country::class)]
#[ORM\JoinColumn(name: 'country_id', referencedColumnName: 'id')]
private Country $country;

public function getId(): ?int
public function getId(): int|null
{
return $this->id;
}
Expand Down
22 changes: 9 additions & 13 deletions tests/Assets/Entity/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="doctrine_orm_module_country")
*/
#[ORM\Entity]
#[ORM\Table(name: 'doctrine_orm_module_country')]
class Country
{
/**
* @ORM\Id
* @ORM\Column(type="integer");
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected int $id;
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private int $id;

/** @ORM\Column(type="string", nullable=true) */
protected string $name;
#[ORM\Column(type: 'string', nullable: true)]
private string $name;

public function getId(): ?int
public function getId(): int|null
{
return $this->id;
}
Expand Down
22 changes: 9 additions & 13 deletions tests/Assets/Entity/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@
use DateTime;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="doctrine_orm_module_date")
*/
#[ORM\Entity]
#[ORM\Table(name: 'doctrine_orm_module_date')]
class Date
{
/**
* @ORM\Id
* @ORM\Column(type="integer");
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected int $id;
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private int $id;

/** @ORM\Column(type="date", nullable=true) */
protected DateTime $date;
#[ORM\Column(type: 'date', nullable: true)]
private DateTime $date;

public function getId(): ?int
public function getId(): int|null
{
return $this->id;
}
Expand Down
16 changes: 6 additions & 10 deletions tests/Assets/Entity/EntityWithoutRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
*/
#[ORM\Entity]
class EntityWithoutRepository
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private int|null $id = null;

public function getId(): ?int
public function getId(): int|null
{
return $this->id;
}
Expand Down
108 changes: 47 additions & 61 deletions tests/Assets/Entity/FormEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,119 +9,105 @@
use Doctrine\ORM\Mapping as ORM;
use Laminas\Form\Annotation as Form;

/**
* @ORM\Entity
* @ORM\Table(name="doctrine_orm_module_form_entity")
*/
#[ORM\Entity]
#[ORM\Table(name: 'doctrine_orm_module_form_entity')]
class FormEntity
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
protected int $id;

/** @ORM\Column(type="boolean") */
#[ORM\Column(type: 'boolean', nullable: false)]
protected bool $bool;

/** @ORM\Column(type="boolean") */
#[ORM\Column(type: 'boolean', nullable: false)]
protected bool $boolean;

/** @ORM\Column(type="float") */
#[ORM\Column(type: 'float', nullable: false)]
protected float $float;

/** @ORM\Column(type="bigint") */
protected int $bigint;
#[ORM\Column(type: 'bigint', nullable: false)]
protected string $bigint;

/** @ORM\Column(type="integer") */
#[ORM\Column(type: 'integer', nullable: false)]
protected int $integer;

/** @ORM\Column(type="smallint") */
#[ORM\Column(type: 'smallint', nullable: false)]
protected int $smallint;

/** @ORM\Column(type="datetime") */
#[ORM\Column(type: 'datetime', nullable: false)]
protected DateTime $datetime;

/** @ORM\Column(type="datetime_immutable") */
protected DateTime $datetimeImmutable;
#[ORM\Column(type: 'datetime_immutable', nullable: false)]
protected DateTimeImmutable $datetimeImmutable;

/** @ORM\Column(type="datetimetz") */
protected DateTimeImmutable $datetimetz;
#[ORM\Column(type: 'datetimetz', nullable: false)]
protected DateTime $datetimetz;

/** @ORM\Column(type="datetimetz_immutable") */
#[ORM\Column(type: 'datetimetz_immutable', nullable: false)]
protected DateTimeImmutable $datetimetzImmutable;

/** @ORM\Column(type="date") */
#[ORM\Column(type: 'date', nullable: false)]
protected DateTime $date;

/** @ORM\Column(type="time") */
#[ORM\Column(type: 'time', nullable: false)]
protected DateTime $time;

/** @ORM\Column(type="text") */
#[ORM\Column(type: 'text', nullable: false)]
protected string $text;

/** @ORM\Column(type="string", nullable=false, length=20) */
#[ORM\Column(type: 'string', length: 20, nullable: false)]
protected string $string;

/** @ORM\Column(type="string", nullable=true) */
protected ?string $stringNullable = null;
#[ORM\Column(type: 'string', nullable: true)]
protected string|null $stringNullable = null;

/** @ORM\OneToOne(targetEntity="Target") */
#[ORM\OneToOne(targetEntity: Target::class)]
protected Target $targetOne;

/**
* @ORM\OneToOne(targetEntity="Target")
* @ORM\JoinColumn(nullable=true)
*/
protected ?Target $targetOneNullable = null;

/**
* @ORM\OneToOne(targetEntity="Target")
* @ORM\JoinColumn(nullable=true)
*
* @Form\Type("DoctrineModule\Form\Element\ObjectSelect")
* @Form\Options({"empty_option":null})
*/
protected ?Target $noDisplayEmptyOption = null;
#[ORM\OneToOne(targetEntity: Target::class)]
#[ORM\JoinColumn(nullable: true)]
protected Target|null $targetOneNullable = null;

/**
* @ORM\OneToMany(targetEntity="FormEntityTarget", mappedBy="formEntity")
*
* @var Target[]
* @Form\Type("File")
* @Form\Options({"label":"Image"})
*/
protected array $targetMany;
#[ORM\Column(type: 'string', length: 256, nullable: true)]
#[ORM\JoinColumn(nullable: true)]
protected string $image;

/**
* @ORM\Column(type="integer")
*
* @Form\Options({"label":"Please Choose", "value_options":{"f":"false","t":"true"}})
* @Form\Type("Radio")
*/
#[ORM\Column(type: 'integer')]
protected int $specificType;

/**
* @ORM\OneToMany(targetEntity="FormEntityTarget", mappedBy="formEntityMulti")
*
* @Form\Type("DoctrineORMModule\Form\Element\EntityMultiCheckbox")
*
* @var FormEntityTarget[]
*/
#[ORM\OneToMany(targetEntity: FormEntityTarget::class, mappedBy: 'formEntityMulti')]
protected array $specificMultiType;

/**
* @ORM\Column(type="integer")
*
* @Form\Options({"label":"Please Choose", "value_options":{"f":"false","t":"true"}})
* @Form\Attributes({"type":"textarea"})
* @Form\Type("DoctrineModule\Form\Element\ObjectSelect")
* @Form\Options({"empty_option":null})
*/
protected int $specificAttributeType;
#[ORM\OneToOne(targetEntity: Target::class)]
#[ORM\JoinColumn(nullable: true)]
protected Target|null $noDisplayEmptyOption = null;

/** @var Target[] */
#[ORM\OneToMany(targetEntity: FormEntityTarget::class, mappedBy: 'formEntity')]
protected array $targetMany;

/**
* @ORM\Column(type="string", length=256)
* @ORM\JoinColumn(nullable=true)
*
* @Form\Type("File")
* @Form\Options({"label":"Image"})
* @Form\Options({"label":"Please Choose", "value_options":{"f":"false","t":"true"}})
* @Form\Attributes({"type":"textarea"})
*/
protected string $image;
#[ORM\Column(type: 'integer')]
protected int $specificAttributeType;
}
4 changes: 1 addition & 3 deletions tests/Assets/Entity/FormEntityTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
*/
/** @ORM\Entity */
class FormEntityTarget
{
/**
Expand Down
Loading

0 comments on commit c936383

Please sign in to comment.