Commit 6548e663 authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

Ajout d'un Embedded, pour voir.

No related merge requests found
Showing with 203 additions and 2 deletions
+203 -2
<?php declare(strict_types=1);
/**
* Copyright (C) 2019 IRSTEA
* All rights reserved.
*
* @copyright 2019 IRSTEA
* @author guillaume.perreal
*/
namespace Irstea\NgModelGeneratorBundle\Tests\Fixtures\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Class Address
*
* @ORM\Embeddable()
*/
final class Address
{
/**
* @var string
*/
private $street;
/**
* @var string
*/
private $postalCode;
/**
* @var string
*/
private $city;
/**
* @var string
*/
private $country;
/**
* Address constructor.
* @param string $street
* @param string $postalCode
* @param string $city
* @param string $country
*/
public function __construct(string $street, string $postalCode, string $city, string $country)
{
$this->street = $street;
$this->postalCode = $postalCode;
$this->city = $city;
$this->country = $country;
}
/**
* Get street.
*
* @return string
*/
public function getStreet(): string
{
return $this->street;
}
/**
* Set street.
*
* @param string $street
*/
public function setStreet(string $street): void
{
$this->street = $street;
}
/**
* Get postalCode.
*
* @return string
*/
public function getPostalCode(): string
{
return $this->postalCode;
}
/**
* Set postalCode.
*
* @param string $postalCode
*/
public function setPostalCode(string $postalCode): void
{
$this->postalCode = $postalCode;
}
/**
* Get city.
*
* @return string
*/
public function getCity(): string
{
return $this->city;
}
/**
* Set city.
*
* @param string $city
*/
public function setCity(string $city): void
{
$this->city = $city;
}
/**
* Get country.
*
* @return string
*/
public function getCountry(): string
{
return $this->country;
}
/**
* Set country.
*
* @param string $country
*/
public function setCountry(string $country): void
{
$this->country = $country;
}
/**
* @param Address $other
* @return bool
*/
public function isEqualTo(Address $other): bool
{
return $other->street === $this->street
&& $other->postalCode === $this->postalCode
&& $other->city === $this->city
&& $other->country === $this->city;
}
}
<?php declare(strict_types=1);
/**
* Copyright (C) 2019 IRSTEA
* All rights reserved.
*
* @copyright 2019 IRSTEA
* @author guillaume.perreal
*/
namespace Irstea\NgModelGeneratorBundle\Tests\Fixtures\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Trait GeolocalizedTrait
*/
trait GeolocalizedTrait
{
/**
* @var Address|null
* @ORM\Embedded(class=Address::class)
*/
private $address;
/**
* Get address.
*
* @return Address|null
*/
public function getAddress(): ?Address
{
return $this->address;
}
/**
* Get address.
*
* @return Address|null
*/
public function setAddress(?Address $address): void
{
$this->address = $address;
}
}
......@@ -27,6 +27,7 @@ final class Person
{
use EntityTrait;
use TimestampedTrait;
use GeolocalizedTrait;
/**
* @var string
......@@ -81,7 +82,7 @@ final class Person
* @param Structure|null $affectation
* @throws \Exception
*/
public function __construct(string $firstName, string $lastName, string $email = null, string $phoneNumber = null, Structure $affectation = null)
public function __construct(string $firstName, string $lastName, string $email = null, string $phoneNumber = null, Structure $affectation = null, Address $address = null)
{
$this->createId();
$this->created();
......@@ -94,6 +95,7 @@ final class Person
$this->managedProjects = new ArrayCollection();
$this->participeTo = new ArrayCollection();
$this->affectation = $affectation;
$this->address = $address;
}
/**
......
......@@ -26,6 +26,7 @@ class Structure
{
use EntityTrait;
use TimestampedTrait;
use GeolocalizedTrait;
/**
* @ORM\Column()
......@@ -49,14 +50,17 @@ class Structure
* Structure constructor.
* @param string $name
* @param Structure|null $parent
* @param Address|null $address
* @throws \Exception
*/
public function __construct(string $name, self $parent = null)
public function __construct(string $name, self $parent = null, Address $address = null)
{
$this->createId();
$this->created();
$this->name = $name;
$this->parent = $parent;
$this->address = $address;
$this->children = New ArrayCollection();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment