fix person

This commit is contained in:
Julien Fastré 2014-11-07 12:15:00 +01:00
parent 9e65354cfc
commit 9d313dd68f
3 changed files with 23 additions and 268 deletions

View File

@ -12,7 +12,7 @@ use Chill\PersonBundle\Entity\Person;
*
* @author Julien Fastré <julien arobase fastre point info>
*/
class LoadPeople extends AbstractFixture {
class LoadPeople extends AbstractFixture implements OrderedFixtureInterface {
public function prepare() {
@ -39,7 +39,7 @@ class LoadPeople extends AbstractFixture {
}
public function getOrder() {
return 1302;
return 10000;
}
@ -56,7 +56,7 @@ class LoadPeople extends AbstractFixture {
do {
echo "add a person...";
$i++;
$sex = $this->genres[array_rand($this->genres)];
@ -86,9 +86,6 @@ class LoadPeople extends AbstractFixture {
'DateOfBirth' => "1960-10-12",
'PlaceOfBirth' => "Ottignies Louvain-La-Neuve",
'Genre' => $sex,
'CivilUnion' => $this->CivilUnions[array_rand($this->CivilUnions)],
'NbOfChild' => $this->NbOfChild[array_rand($this->NbOfChild)],
'BelgianNationalNumber' => '811016-269-24',
'Email' => "Email d'un ami: roger@tt.com",
'CountryOfBirth' => 'France',
'Nationality' => 'Russie'
@ -112,6 +109,8 @@ class LoadPeople extends AbstractFixture {
}
$manager->persist($p);
echo "add person'".$p->__toString()."'\n";
} while ($i <= 100);
$manager->flush();
@ -135,11 +134,6 @@ class LoadPeople extends AbstractFixture {
private $genres = array(Person::GENRE_MAN, Person::GENRE_WOMAN);
private $CivilUnions = array(Person::CIVIL_COHAB, Person::CIVIL_DIVORCED,
Person::CIVIL_SEPARATED, Person::CIVIL_SINGLE, Person::CIVIL_UNKNOW,
Person::CIVIL_WIDOW);
private $NbOfChild = array(0, 0, 1, 1, 1, 1, 1, 2, 2, 3, 4, 5, 6);
private $years = array();
@ -154,9 +148,6 @@ class LoadPeople extends AbstractFixture {
'DateOfBirth' => "1960-10-12",
'PlaceOfBirth' => "Ottignies Louvain-La-Neuve",
'Genre' => Person::GENRE_MAN,
'CivilUnion' => Person::CIVIL_DIVORCED,
'NbOfChild' => 0,
'BelgianNationalNumber' => '12-10-16-269-24',
'Email' => "Email d'un ami: roger@tt.com",
'CountryOfBirth' => 'France',
'Nationality' => 'Russie'

View File

@ -2,16 +2,13 @@
namespace Chill\PersonBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\ExecutionContextInterface;
use CL\CLHistoryBundle\Entity\IsHistoryContainer;
use CL\CLHistoryBundle\Entity\HasHistory;
use CL\CLHistoryBundle\Entity\HistoryHelper;
use Chill\MainBundle\Entity\Country;
/**
* Person
*/
class Person implements IsHistoryContainer, HasHistory {
class Person {
/**
* @var integer
*/
@ -42,48 +39,14 @@ class Person implements IsHistoryContainer, HasHistory {
*/
private $genre;
const GENRE_MAN = 'MAN';
const GENRE_WOMAN = 'WOM';
/**
* @var string
*/
private $civil_union = self::CIVIL_UNKNOW;
/*Célibataire
Marié(e)
Veuf Veuve
Séparé(e)
Divorcé(e)
Cohabitant légal
Indéterminé
ou une valeur vide lorsque la donnée nest pas connue*/
const CIVIL_SINGLE = 'single';
const CIVIL_WIDOW = 'widow';
const CIVIL_SEPARATED = 'separated';
const CIVIL_DIVORCED = 'divorced';
const CIVIL_COHAB = 'cohab';
const CIVIL_UNKNOW = 'unknow';
/**
* @var integer
*/
private $nbOfChild = 0;
/**
* @var string
*/
private $belgian_national_number;
const GENRE_MAN = 'man';
const GENRE_WOMAN = 'woman';
/**
* @var string
*/
private $memo = '';
/**
* @var string
*/
private $address = '';
/**
* @var string
*/
@ -110,18 +73,7 @@ ou une valeur vide lorsque la donnée nest pas connue*/
* @var boolean
*/
private $proxyHistoryOpenState = false;
const HISTORY_DOMAIN = 'person';
/**
*
* @var string
*/
private $historyId = null;
const ACTION_UPDATE = 'update';
const ACTION_CREATE = 'create';
@ -134,9 +86,6 @@ ou une valeur vide lorsque la donnée nest pas connue*/
$this->open($opening);
//create an helper with key "update", and set "creation" instead
$this->getHistoryHelper(self::ACTION_UPDATE)
->setAction(self::ACTION_CREATE);
}
/**
@ -288,11 +237,7 @@ ou une valeur vide lorsque la donnée nest pas connue*/
*/
public function setName($name)
{
if ($name !== $this->name) {
$this->getHistoryHelper(self::ACTION_UPDATE)
->registerChange('name', $this->name, $name);
$this->name = $name;
}
$this->name = $name;
return $this;
}
@ -406,7 +351,7 @@ ou une valeur vide lorsque la donnée nest pas connue*/
/**
* return gender as a Numeric form.
* Useful for translation :-)
* This is used for translations
* @return int
*/
public function getGenreNumeric() {
@ -416,83 +361,6 @@ ou une valeur vide lorsque la donnée nest pas connue*/
return 0;
}
/**
* Set civil_union
*
* @param string $civilUnion
* @return Person
*/
public function setCivilUnion($civilUnion)
{
if ($this->civil_union !== $civilUnion) {
$this->getHistoryHelper(self::ACTION_UPDATE)
->registerChange('civil_union', $this->civil_union, $civilUnion);
$this->civil_union = $civilUnion;
}
return $this;
}
/**
* Get civil_union
*
* @return string
*/
public function getCivilUnion()
{
return $this->civil_union;
}
/**
* Set nbOfChild
*
* @param integer $nbOfChild
* @return Person
*/
public function setNbOfChild($nbOfChild)
{
$this->nbOfChild = $nbOfChild;
return $this;
}
/**
* Get nbOfChild
*
* @return integer
*/
public function getNbOfChild()
{
return $this->nbOfChild;
}
/**
* Set belgian_national_number
*
* @param string $belgianNationalNumber
* @return Person
*/
public function setBelgianNationalNumber($belgianNationalNumber)
{
if ($belgianNationalNumber === null) {
$belgianNationalNumber = '';
}
$this->belgian_national_number = $belgianNationalNumber;
return $this;
}
/**
* Get belgian_national_number
*
* @return string
*/
public function getBelgianNationalNumber()
{
return $this->belgian_national_number;
}
/**
* Set memo
*
@ -527,33 +395,6 @@ ou une valeur vide lorsque la donnée nest pas connue*/
return $this->memo;
}
/**
* Set address
*
* @param string $address
* @return Person
*/
public function setAddress($address)
{
if ($address === null) {
$address = '';
}
$this->address = $address;
return $this;
}
/**
* Get address
*
* @return string
*/
public function getAddress()
{
return $this->address;
}
/**
* Set email
*
@ -584,28 +425,19 @@ ou une valeur vide lorsque la donnée nest pas connue*/
/**
* Set countryOfBirth
*
* @param \CL\Chill\MainBundle\Entity\Country $countryOfBirth
* @param Chill\MainBundle\Entity\Country $countryOfBirth
* @return Person
*/
public function setCountryOfBirth(\CL\Chill\MainBundle\Entity\Country $countryOfBirth = null)
{
if ($this->countryOfBirth->getId() !== $countryOfBirth->getId()) {
$this->getHistoryHelper(self::ACTION_UPDATE)
->registerChange('country_of_birth',
$this->countryOfBirth->getLabel(),
$countryOfBirth->getLabel());
$this->countryOfBirth = $countryOfBirth;
}
public function setCountryOfBirth(Country $countryOfBirth = null)
{
$this->countryOfBirth = $countryOfBirth;
return $this;
}
/**
* Get countryOfBirth
*
* @return \CL\Chill\MainBundle\Entity\Country
* @return Chill\MainBundle\Entity\Country
*/
public function getCountryOfBirth()
{
@ -615,10 +447,10 @@ ou une valeur vide lorsque la donnée nest pas connue*/
/**
* Set nationality
*
* @param \CL\Chill\MainBundle\Entity\Country $nationality
* @param Chill\MainBundle\Entity\Country $nationality
* @return Person
*/
public function setNationality(\CL\Chill\MainBundle\Entity\Country $nationality = null)
public function setNationality(Country $nationality = null)
{
$this->nationality = $nationality;
@ -628,7 +460,7 @@ ou une valeur vide lorsque la donnée nest pas connue*/
/**
* Get nationality
*
* @return \CL\Chill\MainBundle\Entity\Country
* @return Chill\MainBundle\Entity\Country
*/
public function getNationality()
{
@ -756,56 +588,4 @@ ou une valeur vide lorsque la donnée nest pas connue*/
return true;
}
public function getDomain() {
return self::HISTORY_DOMAIN;
}
public function getHistoryId() {
return $this->historyId;
}
public function setHistoryId($id) {
$this->historyId = $id;
}
/**
*
* @var \CL\CLHistoryBundle\Entity\HistoryHelper
*/
private $historyHelper = array();
private function getHistoryHelper($helper) {
if (!isset($this->historyHelper[$helper])) {
$this->historyHelper[$helper] = new HistoryHelper();
$this->historyHelper[$helper]->setAction($helper);
}
return $this->historyHelper[$helper];
}
public function getEntityName() {
return 'person';
}
public function getHistory() {
$histories = array();
foreach ($this->historyHelper as $historyHelper) {
$histories = $histories->toArray();
}
return $histories;
}
public function getParentContainers() {
return array($this);
}
public function getVersion() {
return 0;
}
}

View File

@ -25,38 +25,22 @@ Chill\PersonBundle\Entity\Person:
default: ''
genre:
type: string
length: 3
civil_union:
type: string
length: 30
nullable: true
nbOfChild:
type: smallint
nullable: true
belgian_national_number:
type: string
length: 16
nullable: true
length: 9
memo:
type: text
default: ''
address:
type: text
email:
type: text
proxyHistoryOpenState:
type: boolean
name: proxy_open
historyId:
type: string
length: 40
manyToOne:
countryOfBirth:
targetEntity: CL\Chill\MainBundle\Entity\Country
targetEntity: Chill\MainBundle\Entity\Country
inversedBy: birthsIn
nullable: true
nationality:
targetEntity: CL\Chill\MainBundle\Entity\Country
targetEntity: Chill\MainBundle\Entity\Country
inversedBy: nationals
nullable: true
oneToMany: