Merge branch 'sf4' of framagit.org:Chill-project/Chill-Person into sf4

This commit is contained in:
Tchama 2020-07-28 16:57:06 +02:00
commit 6734295be7
23 changed files with 541 additions and 312 deletions

View File

@ -3,7 +3,7 @@
namespace Chill\PersonBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
class AdminController extends Controller
{

View File

@ -24,6 +24,9 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Chill\MainBundle\Timeline\TimelineBuilder;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
/**
*
@ -38,14 +41,31 @@ class TimelinePersonController extends Controller
*/
protected $eventDispatcher;
/**
*
* @var TimelineBuilder
*/
protected $timelineBuilder;
/**
*
* @var PaginatorFactory
*/
protected $paginatorFactory;
/**
* TimelinePersonController constructor.
*
* @param EventDispatcherInterface $eventDispatcher
*/
public function __construct(EventDispatcherInterface $eventDispatcher)
{
public function __construct(
EventDispatcherInterface $eventDispatcher,
TimelineBuilder $timelineBuilder,
PaginatorFactory $paginatorFactory
) {
$this->eventDispatcher = $eventDispatcher;
$this->timelineBuilder = $timelineBuilder;
$this->paginatorFactory = $paginatorFactory;
}
@ -59,24 +79,20 @@ class TimelinePersonController extends Controller
throw $this->createNotFoundException();
}
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
/* @var $timelineBuilder \Chill\MainBundle\Timeline\TimelineBuilder */
$timelineBuilder = $this->get('chill.main.timeline_builder');
$paginatorFactory = $this->get('chill_main.paginator_factory');
$nbItems = $timelineBuilder->countItems('person',
$nbItems = $this->timelineBuilder->countItems('person',
[ 'person' => $person ]
);
$paginator = $paginatorFactory->create($nbItems);
$paginator = $this->paginatorFactory->create($nbItems);
$event = new PrivacyEvent($person, array('action' => 'timeline'));
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
return $this->render('ChillPersonBundle:Timeline:index.html.twig', array
(
'timeline' => $timelineBuilder->getTimelineHTML(
'timeline' => $this->timelineBuilder->getTimelineHTML(
'person',
array('person' => $person),
$paginator->getCurrentPage()->getFirstItemNumber(),

View File

@ -28,36 +28,74 @@ use Chill\MainBundle\Entity\User;
/**
* AccompanyingPeriod
*
* @ORM\Entity()
* @ORM\Table(name="chill_person_accompanying_period")
*/
class AccompanyingPeriod
{
/** @var integer */
/**
* @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/** @var \DateTime */
/**
* @var \DateTime
*
* @ORM\Column(type="date")
*/
private $openingDate;
/** @var \DateTime */
private $closingDate;
/**
* @var \DateTime
*
* @ORM\Column(type="date", nullable=true)
*/
private $closingDate = null;
/** @var string */
/**
* @var string
*
* @ORM\Column(type="text")
*/
private $remark = '';
/** @var \Chill\PersonBundle\Entity\Person */
/**
* @var Person
*
* @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\Person",
* inversedBy="accompanyingPeriods",
* cascade={"refresh"})
*/
private $person;
/** @var AccompanyingPeriod\ClosingMotive */
/**
* @var AccompanyingPeriod\ClosingMotive
*
* @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive")
* @ORM\JoinColumn(nullable=true)
*/
private $closingMotive = null;
/**
* The user making the accompanying
*
* @var User
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
* @ORM\JoinColumn(nullable=true)
*/
private $user;
/**
*
* AccompanyingPeriod constructor.
*
* @param \DateTime $dateOpening
* @uses AccompanyingPeriod::setClosingDate()
*/
@ -125,7 +163,6 @@ class AccompanyingPeriod
}
/**
*
* @return boolean
*/
public function isOpen(): bool
@ -170,14 +207,14 @@ class AccompanyingPeriod
/**
* Set person.
*
*
* For consistency, you should use Person::addAccompanyingPeriod instead.
*
* @param \Chill\PersonBundle\Entity\Person $person
* @param Person $person
* @return AccompanyingPeriod
* @see Person::addAccompanyingPeriod
*/
public function setPerson(\Chill\PersonBundle\Entity\Person $person = null)
public function setPerson(Person $person = null)
{
$this->person = $person;
@ -187,18 +224,25 @@ class AccompanyingPeriod
/**
* Get person
*
* @return \Chill\PersonBundle\Entity\Person
* @return Person
*/
public function getPerson()
{
return $this->person;
}
/**
* @return AccompanyingPeriod\ClosingMotive
*/
public function getClosingMotive()
{
return $this->closingMotive;
}
/**
* @param AccompanyingPeriod\ClosingMotive|null $closingMotive
* @return $this
*/
public function setClosingMotive(AccompanyingPeriod\ClosingMotive $closingMotive = null)
{
$this->closingMotive = $closingMotive;
@ -224,14 +268,19 @@ class AccompanyingPeriod
return end($periods) === $this;
}
/**
*/
public function reOpen()
{
$this->setClosingDate(null);
$this->setClosingMotive(null);
}
/// VALIDATION function
public function isDateConsistent(ExecutionContextInterface $context) {
/**
* Validation function
*/
public function isDateConsistent(ExecutionContextInterface $context)
{
if ($this->isOpen()) {
return;
}
@ -248,7 +297,8 @@ class AccompanyingPeriod
*
* @return boolean
*/
public function isClosingAfterOpening() {
public function isClosingAfterOpening()
{
$diff = $this->getOpeningDate()->diff($this->getClosingDate());
if ($diff->invert === 0) {
@ -258,11 +308,18 @@ class AccompanyingPeriod
}
}
/**
* @return User|null
*/
function getUser(): ?User
{
return $this->user;
}
/**
* @param User $user
* @return AccompanyingPeriod
*/
function setUser(User $user): self
{
$this->user = $user;
@ -270,5 +327,4 @@ class AccompanyingPeriod
return $this;
}
}

View File

@ -20,51 +20,75 @@
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
/**
* ClosingMotive give an explanation why we closed the Accompanying period
*
* @ORM\Entity(
* repositoryClass="Chill\PersonBundle\Repository\ClosingMotiveRepository")
* @ORM\Table(name="chill_person_closingmotive")
*/
class ClosingMotive
{
/**
* @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var array
*
* @ORM\Column(type="json_array")
*/
private $name;
/**
*
* @var boolean
*
* @ORM\Column(type="boolean")
*/
private $active = true;
/**
*
* @var self
*
* @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive",
* inversedBy="children")
*/
private $parent = null;
/**
* child Accompanying periods
*
* Child Accompanying periods
* @var Collection
*
* @ORM\OneToMany(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive",
* mappedBy="parent")
*/
private $children;
/**
*
* @var float
*
* @ORM\Column(type="float")
*/
private $ordering = 0.0;
/**
* ClosingMotive constructor.
*/
public function __construct()
{
$this->children = new \Doctrine\Common\Collections\ArrayCollection();
$this->children = new ArrayCollection();
}
/**
@ -101,11 +125,18 @@ class ClosingMotive
return $this->name;
}
/**
* @return bool
*/
public function isActive(): bool
{
return $this->active;
}
/**
* @param bool $active
* @return $this
*/
public function setActive(bool $active)
{
$this->active = $active;
@ -118,17 +149,27 @@ class ClosingMotive
return $this;
}
/**
* @return ClosingMotive
*/
public function getParent()
{
return $this->parent;
}
/**
* @return Collection
*/
public function getChildren(): Collection
{
return $this->children;
}
/**
* @param ClosingMotive|null $parent
* @return ClosingMotive
*/
public function setParent(?ClosingMotive $parent): ClosingMotive
{
$this->parent = $parent;
@ -139,7 +180,11 @@ class ClosingMotive
return $this;
}
/**
* @param Collection $children
* @return ClosingMotive
*/
public function setChildren(Collection $children): ClosingMotive
{
$this->children = $children;
@ -147,6 +192,10 @@ class ClosingMotive
return $this;
}
/**
* @param ClosingMotive $child
* @return ClosingMotive
*/
public function addChildren(ClosingMotive $child): ClosingMotive
{
if ($this->children->contains($child)) {
@ -159,6 +208,10 @@ class ClosingMotive
return $this;
}
/**
* @param ClosingMotive $child
* @return ClosingMotive
*/
public function removeChildren(ClosingMotive $child): ClosingMotive
{
if ($this->children->removeElement($child)) {
@ -168,33 +221,52 @@ class ClosingMotive
return $this;
}
/**
* @return float
*/
public function getOrdering(): float
{
return $this->ordering;
}
/**
* @param float $ordering
* @return $this
*/
public function setOrdering(float $ordering)
{
$this->ordering = $ordering;
return $this;
}
/**
* @return bool
*/
public function isChild(): bool
{
return $this->parent !== null;
}
/**
* @return bool
*/
public function isParent(): bool
{
return $this->children->count() > 0;
}
/**
* @return bool
*/
public function isLeaf(): bool
{
return $this->children->count() === 0;
}
/**
* @return bool
*/
public function hasParent(): bool
{
return $this->parent !== null;

View File

@ -20,18 +20,28 @@
namespace Chill\PersonBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* MaritalStatus
*
* @ORM\Entity()
* @ORM\Table(name="chill_person_marital_status")
* @ORM\HasLifecycleCallbacks()
*/
class MaritalStatus
{
/**
* @var string
*
* @ORM\Id()
* @ORM\Column(type="string", length=7)
*/
private $id;
/**
* @var string array
* @ORM\Column(type="json_array")
*/
private $name;

View File

@ -22,110 +22,248 @@ namespace Chill\PersonBundle\Entity;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Country;
use Chill\PersonBundle\Entity\MaritalStatus;
use Doctrine\Common\Collections\ArrayCollection;
use Chill\MainBundle\Entity\HasCenterInterface;
use Chill\MainBundle\Entity\Address;
use Doctrine\Common\Collections\Criteria;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
* Person
* Person Class
*
* @ORM\Entity(repositoryClass="Chill\PersonBundle\Repository\PersonRepository")
* @ORM\Table(name="chill_person_person",
* indexes={@ORM\Index(
* name="person_names",
* columns={"firstName", "lastName"}
* )})
* sf4 check index name
* @ORM\HasLifecycleCallbacks()
*/
class Person implements HasCenterInterface {
/** @var integer The person's id */
class Person implements HasCenterInterface
{
/**
* The person's id
* @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/** @var string The person's first name */
/**
* The person's first name
* @var string
*
* @ORM\Column(type="string", length=255)
*/
private $firstName;
/** @var string The person's last name */
/**
* The person's last name
* @var string
*
* @ORM\Column(type="string", length=255)
*/
private $lastName;
/**
* @var Collection
*
* @var \Doctrine\Common\Collections\Collection
* @ORM\OneToMany(
* targetEntity="Chill\PersonBundle\Entity\PersonAltName",
* mappedBy="person",
* cascade={"persist", "remove", "merge", "detach"},
* orphanRemoval=true)
*/
private $altNames;
/** @var \DateTime The person's birthdate */
/**
* The person's birthdate
* @var \DateTime
*
* @ORM\Column(type="date", nullable=true)
*/
private $birthdate; //to change in birthdate
/** @var string The person's place of birth */
/**
* The person's place of birth
* @var string
*
* @ORM\Column(type="string", length=255, name="place_of_birth")
*/
private $placeOfBirth = '';
/** @var \Chill\MainBundle\Entity\Country The person's country of birth */
/**
* The person's country of birth
* @var Country
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
*
* sf4 check: option inversedBy="birthsIn" return error mapping !!
*
* @ORM\JoinColumn(nullable=true)
*/
private $countryOfBirth;
/** @var \Chill\MainBundle\Entity\Country The person's nationality */
/**
* The person's nationality
* @var Country
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
*
* sf4 check: option inversedBy="nationals" return error mapping !!
*
* @ORM\JoinColumn(nullable=true)
*/
private $nationality;
/** @var string The person's gender */
/**
* The person's gender
* @var string
*
* @ORM\Column(type="string", length=9, nullable=true)
*/
private $gender;
const MALE_GENDER = 'man';
const FEMALE_GENDER = 'woman';
const BOTH_GENDER = 'both';
/** @var \Chill\PersonBundle\Entity\MaritalStatus The marital status of the person */
/**
* The marital status of the person
* @var MaritalStatus
*
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\MaritalStatus")
* @ORM\JoinColumn(nullable=true)
*/
private $maritalStatus;
/** @var string Contact information for contacting the person */
/**
* Contact information for contacting the person
* @var string
*
* @ORM\Column(type="text", nullable=true)
*/
private $contactInfo = '';
/** @var string The person's email */
/**
* The person's email
* @var string
*
* @ORM\Column(type="text", nullable=true)
*/
private $email = '';
/** @var string The person's phonenumber */
/**
* The person's phonenumber
* @var string
*
* @ORM\Column(type="text", length=40, nullable=true)
*/
private $phonenumber = '';
/** @var string The person's mobile phone number */
/**
* The person's mobile phone number
* @var string
*
* @ORM\Column(type="text", length=40, nullable=true)
*/
private $mobilenumber = '';
//TO-ADD : caseOpeningDate
//TO-ADD caseOpeningDate
//TO-ADD nativeLanguag
/**
* @var \Doctrine\Common\Collections\ArrayCollection The person's spoken
* languages (ArrayCollection of Languages)
* The person's spoken languages
* @var ArrayCollection
*
* @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\Language")
* @ORM\JoinTable(
* name="persons_spoken_languages",
* joinColumns={@ORM\JoinColumn(name="person_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="language_id", referencedColumnName="id")}
* )
*/
private $spokenLanguages;
/** @var \Chill\MainBundle\Entity\Center The person's center */
/**
* The person's center
* @var Center
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Center")
* @ORM\JoinColumn(nullable=false)
*/
private $center;
/**
* @var \Doctrine\Common\Collections\ArrayCollection The person's
* accompanying periods (when the person was accompanied by the center)*/
* The person's accompanying periods (when the person was accompanied by the center)
* @var ArrayCollection
*
* @ORM\OneToMany(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
* mappedBy="person",
* cascade={"persist", "remove", "merge", "detach"})
*/
private $accompanyingPeriods; //TO-CHANGE in accompanyingHistory
/** @var string A remark over the person */
/**
* A remark over the person
* @var string
*
* @ORM\Column(type="text")
*/
private $memo = ''; // TO-CHANGE in remark
/**
* @var boolean
* @deprecated
*
* @ORM\Column(type="boolean")
*/
private $proxyAccompanyingPeriodOpenState = false; //TO-DELETE ?
/** @var array Array where customfield's data are stored */
/**
* Array where customfield's data are stored
* @var array
*
* @ORM\Column(type="json_array")
*/
private $cFData;
/**
* Addresses
* @var Collection
*
* @var \Doctrine\Common\Collections\Collection
* @ORM\ManyToMany(
* targetEntity="Chill\MainBundle\Entity\Address",
* cascade={"persist", "remove", "merge", "detach"})
* @ORM\JoinTable(name="chill_person_persons_to_addresses")
* @ORM\OrderBy({"validFrom" = "DESC"})
*/
private $addresses;
/**
* @var string
*
* @ORM\Column(type="text", nullable=true)
*/
private $fullnameCanonical;
public function __construct(\DateTime $opening = null) {
/**
* Person constructor.
*
* @param \DateTime|null $opening
*/
public function __construct(\DateTime $opening = null)
{
$this->accompanyingPeriods = new ArrayCollection();
$this->spokenLanguages = new ArrayCollection();
$this->addresses = new ArrayCollection();
@ -139,15 +277,20 @@ class Person implements HasCenterInterface {
}
/**
* @param \Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod
* @param AccompanyingPeriod $accompanyingPeriod
* @uses AccompanyingPeriod::setPerson
*/
public function addAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod) {
public function addAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod)
{
$accompanyingPeriod->setPerson($this);
$this->accompanyingPeriods->add($accompanyingPeriod);
}
public function removeAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod) {
/**
* @param AccompanyingPeriod $accompanyingPeriod
*/
public function removeAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod)
{
$this->accompanyingPeriods->remove($accompanyingPeriod);
}
@ -161,15 +304,15 @@ class Person implements HasCenterInterface {
*
* To check if the Person and its accompanying period is consistent, use validation.
*
* @param \Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod
* @param AccompanyingPeriod $accompanyingPeriod
*/
public function open(AccompanyingPeriod $accompanyingPeriod) {
public function open(AccompanyingPeriod $accompanyingPeriod)
{
$this->proxyAccompanyingPeriodOpenState = true;
$this->addAccompanyingPeriod($accompanyingPeriod);
}
/**
*
* Set the Person file as closed at the given date.
*
* For update a closing date, you should update AccompanyingPeriod instance
@ -190,7 +333,8 @@ class Person implements HasCenterInterface {
*
* @return AccompanyingPeriod
*/
public function getOpenedAccompanyingPeriod() {
public function getOpenedAccompanyingPeriod()
{
if ($this->isOpen() === false) {
return null;
}
@ -214,10 +358,10 @@ class Person implements HasCenterInterface {
}
/**
*
* @return \Doctrine\Common\Collections\ArrayCollection
* @return ArrayCollection
*/
public function getAccompanyingPeriods() {
public function getAccompanyingPeriods()
{
return $this->accompanyingPeriods;
}
@ -227,7 +371,8 @@ class Person implements HasCenterInterface {
*
* @return AccompanyingPeriod[]
*/
public function getAccompanyingPeriodsOrdered() {
public function getAccompanyingPeriodsOrdered()
{
$periods = $this->getAccompanyingPeriods()->toArray();
//order by date :
@ -332,18 +477,29 @@ class Person implements HasCenterInterface {
return $this->lastName;
}
public function getAltNames(): \Doctrine\Common\Collections\Collection
/**
* @return Collection
*/
public function getAltNames(): Collection
{
return $this->altNames;
}
public function setAltNames(\Doctrine\Common\Collections\Collection $altNames)
/**
* @param Collection $altNames
* @return $this
*/
public function setAltNames(Collection $altNames)
{
$this->altNames = $altNames;
return $this;
}
/**
* @param PersonAltName $altName
* @return $this
*/
public function addAltName(PersonAltName $altName)
{
if (FALSE === $this->altNames->contains($altName)) {
@ -354,6 +510,10 @@ class Person implements HasCenterInterface {
return $this;
}
/**
* @param PersonAltName $altName
* @return $this
*/
public function removeAltName(PersonAltName $altName)
{
if ($this->altNames->contains($altName)) {
@ -387,7 +547,6 @@ class Person implements HasCenterInterface {
return $this->birthdate;
}
/**
* Set placeOfBirth
*
@ -443,7 +602,8 @@ class Person implements HasCenterInterface {
* This is used for translations
* @return int
*/
public function getGenderNumeric() {
public function getGenderNumeric()
{
if ($this->getGender() == self::FEMALE_GENDER) {
return 1;
} else {
@ -483,7 +643,7 @@ class Person implements HasCenterInterface {
/**
* Set maritalStatus
*
* @param \Chill\PersonBundle\Entity\MaritalStatus $maritalStatus
* @param MaritalStatus $maritalStatus
* @return Person
*/
public function setMaritalStatus(MaritalStatus $maritalStatus = null)
@ -495,7 +655,7 @@ class Person implements HasCenterInterface {
/**
* Get maritalStatus
*
* @return \Chill\PersonBundle\Entity\MaritalStatus
* @return MaritalStatus
*/
public function getMaritalStatus()
{
@ -600,15 +760,19 @@ class Person implements HasCenterInterface {
{
return $this->nationality;
}
public function getLabel() {
/**
* @return string
*/
public function getLabel()
{
return $this->getFirstName()." ".$this->getLastName();
}
/**
* Get center
*
* @return \Chill\MainBundle\Entity\Center
* @return Center
*/
public function getCenter()
{
@ -618,16 +782,15 @@ class Person implements HasCenterInterface {
/**
* Set the center
*
* @param \Chill\MainBundle\Entity\Center $center
* @param Center $center
* @return \Chill\PersonBundle\Entity\Person
*/
public function setCenter(\Chill\MainBundle\Entity\Center $center)
public function setCenter(Center $center)
{
$this->center = $center;
return $this;
}
/**
* Set cFData
*
@ -700,7 +863,10 @@ class Person implements HasCenterInterface {
{
return $this->mobilenumber;
}
/**
* @return string
*/
public function __toString()
{
return $this->getLabel();
@ -728,14 +894,21 @@ class Person implements HasCenterInterface {
{
return $this->spokenLanguages;
}
/**
* @param Address $address
* @return $this
*/
public function addAddress(Address $address)
{
$this->addresses[] = $address;
return $this;
}
/**
* @param Address $address
*/
public function removeAddress(Address $address)
{
$this->addresses->removeElement($address);
@ -751,7 +924,11 @@ class Person implements HasCenterInterface {
{
return $this->addresses;
}
/**
* @param \DateTime|null $date
* @return null
*/
public function getLastAddress(\DateTime $date = null)
{
if ($date === null) {

View File

@ -7,13 +7,13 @@ use Doctrine\ORM\Mapping as ORM;
/**
* PersonAltName
*
* @ORM\Table(name="person_alt_name")
* @ORM\Table(name="chill_person_alt_name")
* @ORM\Entity(repositoryClass="Chill\PersonBundle\Repository\PersonAltNameRepository")
*/
class PersonAltName
{
/**
* @var int
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
@ -36,16 +36,16 @@ class PersonAltName
private $label;
/**
*
* @var Person
* @ORM\OneToMany(
*
* @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\Person",
* mappedBy="altNames"
* inversedBy="altNames"
* )
*/
private $person;
/**
* Get id.
*
@ -104,11 +104,18 @@ class PersonAltName
return $this->label;
}
/**
* @return Person
*/
public function getPerson(): Person
{
return $this->person;
}
/**
* @param Person|null $person
* @return $this
*/
public function setPerson(?Person $person = null)
{
$this->person = $person;

View File

@ -1,4 +1,5 @@
<?php
/*
* Copyright (C) 2018 Champs-Libres <info@champs-libres.coop>
*
@ -15,31 +16,43 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Chill\PersonBundle\Form\ChoiceLoader;
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\ChoiceList\LazyChoiceList;
use Chill\PersonBundle\Entity\Person;
/**
*
* Class PersonChoiceLoader
*
* @package Chill\PersonBundle\Form\ChoiceLoader
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class PersonChoiceLoader implements ChoiceLoaderInterface
{
/**
*
* @var EntityRepository
*/
protected $personRepository;
/**
* @var array
*/
protected $lazyLoadedPersons = [];
/**
* @var array
*/
protected $centers = [];
/**
* PersonChoiceLoader constructor.
*
* @param EntityRepository $personRepository
* @param array|null $centers
*/
public function __construct(
EntityRepository $personRepository,
array $centers = null
@ -50,11 +63,18 @@ class PersonChoiceLoader implements ChoiceLoaderInterface
}
}
/**
* @return bool
*/
protected function hasCenterFilter()
{
return count($this->centers) > 0;
}
/**
* @param null $value
* @return ChoiceListInterface
*/
public function loadChoiceList($value = null): ChoiceListInterface
{
$list = new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
@ -65,7 +85,12 @@ class PersonChoiceLoader implements ChoiceLoaderInterface
return $list;
}
/**
* @param array $values
* @param null $value
* @return array
*/
public function loadChoicesForValues(array $values, $value = null)
{
$choices = [];
@ -88,6 +113,11 @@ class PersonChoiceLoader implements ChoiceLoaderInterface
return $choices;
}
/**
* @param array $choices
* @param null $value
* @return array|string[]
*/
public function loadValuesForChoices(array $choices, $value = null)
{
$values = [];

View File

@ -31,7 +31,7 @@ use Chill\MainBundle\Entity\GroupCenter;
use Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Entity\Center;
use Chill\PersonBundle\Entity\PersonRepository;
use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Search\PersonSearch;
use Symfony\Component\Translation\TranslatorInterface;
use Chill\PersonBundle\Form\ChoiceLoader\PersonChoiceLoader;
@ -55,7 +55,11 @@ use Symfony\Component\OptionsResolver\Options;
*/
class PickPersonType extends AbstractType
{
/**
* @var PersonRepository
*/
protected $personRepository;
/**
*
* @var \Chill\MainBundle\Entity\User
@ -81,6 +85,7 @@ class PickPersonType extends AbstractType
protected $translator;
public function __construct(
PersonRepository $personRepository,
TokenStorageInterface $tokenStorage,
AuthorizationHelper $authorizationHelper,
UrlGeneratorInterface $urlGenerator,

View File

@ -1,4 +1,5 @@
<?php
/*
* Copyright (C) 2018 Champs-Libres <info@champs-libres.coop>
*
@ -15,36 +16,54 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Chill\PersonBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\Translation\TranslatorInterface;
/**
*
* Class SectionMenuBuilder
*
* @package Chill\PersonBundle\Menu
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class SectionMenuBuilder implements LocalMenuBuilderInterface
{
/**
*
* @var AuthorizationCheckerInterface
*/
protected $authorizationChecker;
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
/**
* @var TranslatorInterface
*/
protected $translator;
/**
* SectionMenuBuilder constructor.
*
* @param AuthorizationCheckerInterface $authorizationChecker
* @param TranslatorInterface $translator
*/
public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator)
{
$this->authorizationChecker = $authorizationChecker;
$this->translator = $translator;
}
/**
* @param $menuId
* @param MenuItem $menu
* @param array $parameters
*/
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
if ($this->authorizationChecker->isGranted(PersonVoter::CREATE)) {
$menu->addChild('Add a person', [
$menu->addChild($this->translator->trans('Add a person'), [
'route' => 'chill_person_new'
])
->setExtras([
@ -53,7 +72,10 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
]);
}
}
/**
* @return array
*/
public static function getMenuIds(): array
{
return [ 'section' ];

View File

@ -1,26 +0,0 @@
Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive:
table: chill_person_closingmotive
type: entity
repositoryClass: Chill\PersonBundle\Repository\ClosingMotiveRepository
id:
id:
type: integer
id: true
generator: { strategy: AUTO }
fields:
name:
type: json_array
active:
type: boolean
ordering:
type: float
options:
default: 0.0
oneToMany:
children:
targetEntity: Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive
mappedBy: parent
manyToOne:
parent:
targetEntity: Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive
inversedBy: children

View File

@ -1,28 +0,0 @@
Chill\PersonBundle\Entity\AccompanyingPeriod:
table: chill_person_accompanying_period
type: entity
id:
id:
type: integer
id: true
generator: { strategy: AUTO }
fields:
openingDate:
type: date
closingDate:
type: date
default: null
nullable: true
remark:
type: text
manyToOne:
person:
targetEntity: Person
inversedBy: accompanyingPeriods
cascade: [refresh]
closingMotive:
targetEntity: Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive
nullable: true
user:
targetEntity: Chill\MainBundle\Entity\User
nullable: true

View File

@ -1,11 +0,0 @@
Chill\PersonBundle\Entity\MaritalStatus:
table: chill_person_marital_status
type: entity
id:
id:
type: string
length: 7
fields:
name:
type: json_array
lifecycleCallbacks: { }

View File

@ -1,99 +0,0 @@
Chill\PersonBundle\Entity\Person:
type: entity
table: chill_person_person
indexes:
person_names:
columns: [firstName, lastName]
repositoryClass: Chill\PersonBundle\Repository\PersonRepository
fields:
id:
type: integer
id: true
generator:
strategy: AUTO
firstName:
type: string
length: 255
lastName:
type: string
length: 255
birthdate:
type: date
nullable: true
placeOfBirth:
type: string
length: 255
column: place_of_birth
default: ''
gender:
type: string
length: 9
nullable: true
memo:
type: text
default: ''
contactInfo:
type: text
nullable: true
email:
type: text
nullable: true
proxyAccompanyingPeriodOpenState:
type: boolean
name: proxy_open
cFData:
type: json_array
phonenumber:
type: text
nullable: true
length: 40
mobilenumber:
type: text
nullable: true
length: 40
fullnameCanonical:
type: text
nullable: true
manyToOne:
countryOfBirth:
targetEntity: Chill\MainBundle\Entity\Country
inversedBy: birthsIn
nullable: true
nationality:
targetEntity: Chill\MainBundle\Entity\Country
inversedBy: nationals
nullable: true
center:
targetEntity: Chill\MainBundle\Entity\Center
nullable: false
maritalStatus:
targetEntity: Chill\PersonBundle\Entity\MaritalStatus
nullable: true
oneToMany:
accompanyingPeriods:
targetEntity: AccompanyingPeriod
mappedBy: person
cascade: [persist, remove, merge, detach]
altNames:
targetEntity: PersonAltName
mappedBy: person
cascade: [persist, remove, merge, detach]
orphanRemoval: true
manyToMany:
spokenLanguages:
targetEntity: Chill\MainBundle\Entity\Language
joinTable:
name: persons_spoken_languages
joinColumns:
person_id:
referencedColumnName: id
inverseJoinColumns:
language_id:
referencedColumnName: id
addresses:
targetEntity: Chill\MainBundle\Entity\Address
orderBy: { 'validFrom': 'DESC' }
joinTable:
name: chill_person_persons_to_addresses
cascade: [persist, remove, merge, detach]
lifecycleCallbacks: { }

View File

@ -1,21 +0,0 @@
Chill\PersonBundle\Entity\PersonAltName:
type: entity
table: chill_person_alt_name
repositoryClass: Chill\PersonBundle\Repository\PersonAltNameRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
key:
type: string
length: 255
label:
type: text
manyToOne:
person:
targetEntity: Person
inversedBy: altNames

View File

@ -11,10 +11,12 @@ services:
- "@doctrine.orm.entity_manager"
tags:
- { name: form.type, alias: select2_chill_marital_status }
chill.person.timeline.accompanying_period_opening:
class: Chill\PersonBundle\Timeline\TimelineAccompanyingPeriodOpening
arguments:
- "@doctrine.orm.entity_manager"
public: true
tags:
- { name: chill.timeline, context: 'person' }
@ -22,6 +24,7 @@ services:
class: Chill\PersonBundle\Timeline\TimelineAccompanyingPeriodClosing
arguments:
- "@doctrine.orm.entity_manager"
public: true
tags:
- { name: chill.timeline, context: 'person' }

View File

@ -11,9 +11,13 @@ services:
Chill\PersonBundle\Controller\TimelinePersonController:
arguments:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$timelineBuilder: '@chill_main.timeline_builder'
$paginatorFactory: '@chill_main.paginator_factory'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AccompanyingPeriodController:
arguments:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AdminController: ~

View File

@ -32,6 +32,7 @@ services:
chill.person.form.type.pick_person:
class: Chill\PersonBundle\Form\Type\PickPersonType
arguments:
- "@chill.person.repository.person"
- "@security.token_storage"
- "@chill.main.security.authorization.helper"
- '@Symfony\Component\Routing\Generator\UrlGeneratorInterface'

View File

@ -2,6 +2,7 @@ services:
Chill\PersonBundle\Menu\SectionMenuBuilder:
arguments:
$authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'
$translator: '@Symfony\Component\Translation\TranslatorInterface'
tags:
- { name: 'chill.menu_builder' }

View File

@ -1,10 +1,11 @@
services:
Chill\PersonBundle\Repository\PersonRepository:
class: Chill\PersonBundle\Person\PersonRepository
chill.person.repository.person:
class: Chill\PersonBundle\Repository\PersonRepository
factory: ['@doctrine.orm.entity_manager', getRepository]
arguments:
- 'Chill\PersonBundle\Entity\Person'
Chill\PersonBundle\Repository\PersonRepository: '@chill.person.repository.person'
Chill\PersonBundle\Repository\ClosingMotiveRepository:
class: Chill\PersonBundle\Repository\ClosingMotiveRepository

View File

@ -2,6 +2,7 @@ services:
chill_person.widget.person_list:
class: Chill\PersonBundle\Widget\PersonListWidget
arguments:
- "@chill.person.repository.person"
- "@doctrine.orm.entity_manager"
- "@chill.main.security.authorization.helper"
- "@security.token_storage"

View File

@ -152,6 +152,7 @@ Back to the person details: Retour aux détails de la personne
Timeline: Historique
Closing the accompanying period: Fermeture de la période d'accompagnement
Opening the accompanying period: Ouverture d'une période d'accompagnement
'Timeline for %name%': 'Historique de %name%'
#roles
CHILL_PERSON_SEE: Voir les personnes

View File

@ -41,6 +41,12 @@ use Chill\CustomFieldsBundle\Entity\CustomField;
*/
class PersonListWidget implements WidgetInterface
{
/**
* Repository for persons
*
* @var EntityRepository
*/
protected $personRepository;
/**
* The entity manager
@ -69,6 +75,7 @@ class PersonListWidget implements WidgetInterface
protected $user;
public function __construct(
EntityRepository $personRepostory,
EntityManager $em,
AuthorizationHelper $authorizationHelper,
TokenStorage $tokenStorage