cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,39 +1,46 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Entity;
use Chill\DocStoreBundle\Entity\Document;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Chill\MainBundle\Entity\HasCenterInterface;
use Chill\MainBundle\Entity\HasScopeInterface;
use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodLinkedWithSocialIssuesEntityInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Doctrine\ORM\Mapping as ORM;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\Center;
use Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Entity\HasCenterInterface;
use Chill\MainBundle\Entity\HasScopeInterface;
use Doctrine\Common\Collections\Collection;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
/**
* Class Activity
* Class Activity.
*
* @package Chill\ActivityBundle\Entity
* @ORM\Entity(repositoryClass="Chill\ActivityBundle\Repository\ActivityRepository")
* @ORM\Table(name="activity")
* @ORM\HasLifecycleCallbacks()
* @ORM\HasLifecycleCallbacks
* @DiscriminatorMap(typeProperty="type", mapping={
* "activity"=Activity::class
* })
* "activity": Activity::class
* })
*/
/*
@@ -46,60 +53,15 @@ use Symfony\Component\Serializer\Annotation\SerializedName;
class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPeriodLinkedWithSocialIssuesEntityInterface
{
const SENTRECEIVED_SENT = 'sent';
const SENTRECEIVED_RECEIVED = 'received';
public const SENTRECEIVED_RECEIVED = 'received';
public const SENTRECEIVED_SENT = 'sent';
/**
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod")
* @Groups({"read"})
*/
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
*/
private User $user;
/**
* @ORM\Column(type="datetime")
*/
private \DateTime $date;
/**
* @ORM\Column(type="time", nullable=true)
*/
private ?\DateTime $durationTime = null;
/**
* @ORM\Column(type="time", nullable=true)
*/
private ?\DateTime $travelTime = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence")
*/
private ?ActivityPresence $attendee = null;
/**
* @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason")
*/
private Collection $reasons;
/**
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialIssue")
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue")
* @Groups({"read"})
*/
private Collection $socialIssues;
/**
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction")
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction")
* @Groups({"read"})
*/
private Collection $socialActions;
private ?AccompanyingPeriod $accompanyingPeriod = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType")
@@ -110,32 +72,89 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
private ActivityType $activityType;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence")
*/
private ?Scope $scope = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
*/
private ?Person $person = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod")
* @Groups({"read"})
*/
private ?AccompanyingPeriod $accompanyingPeriod = null;
private ?ActivityPresence $attendee = null;
/**
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_")
*/
private CommentEmbeddable $comment;
/**
* @ORM\Column(type="datetime")
*/
private DateTime $date;
/**
* @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\StoredObject", cascade={"persist"})
*/
private Collection $documents;
/**
* @ORM\Column(type="time", nullable=true)
*/
private ?DateTime $durationTime = null;
/**
* @ORM\Column(type="boolean", options={"default": false})
*/
private bool $emergency = false;
/**
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"read"})
*/
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
* @groups({"read"})
*/
private ?Location $location = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
*/
private ?Person $person = null;
/**
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person")
* @Groups({"read"})
*/
private ?Collection $persons = null;
/**
* @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason")
*/
private Collection $reasons;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
*/
private ?Scope $scope = null;
/**
* @ORM\Column(type="string", options={"default": ""})
*/
private string $sentReceived = '';
/**
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction")
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction")
* @Groups({"read"})
*/
private Collection $socialActions;
/**
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialIssue")
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue")
* @Groups({"read"})
*/
private Collection $socialIssues;
/**
* @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty")
* @Groups({"read"})
@@ -143,9 +162,14 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
private ?Collection $thirdParties = null;
/**
* @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\StoredObject", cascade={"persist"})
* @ORM\Column(type="time", nullable=true)
*/
private Collection $documents;
private ?DateTime $travelTime = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
*/
private User $user;
/**
* @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User")
@@ -153,23 +177,6 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
*/
private ?Collection $users = null;
/**
* @ORM\Column(type="boolean", options={"default"=false})
*/
private bool $emergency = false;
/**
* @ORM\Column(type="string", options={"default"=""})
*/
private string $sentReceived = '';
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
* @groups({"read"})
*/
private ?Location $location = null;
public function __construct()
{
$this->reasons = new ArrayCollection();
@@ -182,71 +189,25 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
$this->socialActions = new ArrayCollection();
}
public function getId(): ?int
public function addDocument(Document $document): self
{
return $this->id;
}
public function setUser(UserInterface $user): self
{
$this->user = $user;
$this->documents[] = $document;
return $this;
}
public function getUser(): User
/**
* Add a person to the person list.
*/
public function addPerson(?Person $person): self
{
return $this->user;
}
public function setDate(\DateTime $date): self
{
$this->date = $date;
if (null !== $person) {
$this->persons[] = $person;
}
return $this;
}
public function getDate(): \DateTime
{
return $this->date;
}
public function setDurationTime(?\DateTime $durationTime): self
{
$this->durationTime = $durationTime;
return $this;
}
public function getDurationTime(): ?\DateTime
{
return $this->durationTime;
}
public function setTravelTime(\DateTime $travelTime): self
{
$this->travelTime = $travelTime;
return $this;
}
public function getTravelTime(): ?\DateTime
{
return $this->travelTime;
}
public function setAttendee(ActivityPresence $attendee): self
{
$this->attendee = $attendee;
return $this;
}
public function getAttendee(): ?ActivityPresence
{
return $this->attendee;
}
public function addReason(ActivityReason $reason): self
{
$this->reasons->add($reason);
@@ -254,49 +215,6 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
return $this;
}
public function removeReason(ActivityReason $reason): void
{
$this->reasons->removeElement($reason);
}
public function getReasons(): Collection
{
return $this->reasons;
}
public function setReasons(?ArrayCollection $reasons): self
{
$this->reasons = $reasons;
return $this;
}
public function getSocialIssues(): Collection
{
return $this->socialIssues;
}
public function addSocialIssue(SocialIssue $socialIssue): self
{
if (!$this->socialIssues->contains($socialIssue)) {
$this->socialIssues[] = $socialIssue;
}
return $this;
}
public function removeSocialIssue(SocialIssue $socialIssue): self
{
$this->socialIssues->removeElement($socialIssue);
return $this;
}
public function getSocialActions(): Collection
{
return $this->socialActions;
}
public function addSocialAction(SocialAction $socialAction): self
{
if (!$this->socialActions->contains($socialAction)) {
@@ -306,82 +224,51 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
return $this;
}
public function removeSocialAction(SocialAction $socialAction): self
public function addSocialIssue(SocialIssue $socialIssue): self
{
$this->socialActions->removeElement($socialAction);
if (!$this->socialIssues->contains($socialIssue)) {
$this->socialIssues[] = $socialIssue;
}
return $this;
}
public function setActivityType(ActivityType $activityType): self
public function addThirdParty(?ThirdParty $thirdParty): self
{
$this->activityType = $activityType;
if (null !== $thirdParty) {
$this->thirdParties[] = $thirdParty;
}
return $this;
}
public function getActivityType(): ActivityType
public function addUser(?User $user): self
{
return $this->activityType;
}
/**
* @deprecated
*/
public function setType(ActivityType $activityType): self
{
$this->activityType = $activityType;
if (null !== $user) {
$this->users[] = $user;
}
return $this;
}
/**
* @deprecated
*/
public function getType(): ActivityType
{
return $this->activityType;
}
public function setScope(Scope $scope): self
{
$this->scope = $scope;
return $this;
}
public function getScope(): ?Scope
{
return $this->scope;
}
public function setPerson(?Person $person): self
{
$this->person = $person;
return $this;
}
public function getPerson(): ?Person
{
return $this->person;
}
public function getAccompanyingPeriod(): ?AccompanyingPeriod
{
return $this->accompanyingPeriod;
}
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
public function getActivityType(): ActivityType
{
$this->accompanyingPeriod = $accompanyingPeriod;
return $this->activityType;
}
return $this;
public function getAttendee(): ?ActivityPresence
{
return $this->attendee;
}
/**
* get the center
* center is extracted from person
* center is extracted from person.
*/
public function getCenter(): ?Center
{
@@ -397,28 +284,39 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
return $this->comment;
}
public function setComment(CommentEmbeddable $comment): self
public function getDate(): DateTime
{
$this->comment = $comment;
return $this;
return $this->date;
}
/**
* Add a person to the person list
*/
public function addPerson(?Person $person): self
public function getDocuments(): Collection
{
if (null !== $person) {
$this->persons[] = $person;
}
return $this;
return $this->documents;
}
public function removePerson(Person $person): void
public function getDurationTime(): ?DateTime
{
$this->persons->removeElement($person);
return $this->durationTime;
}
public function getEmergency(): bool
{
return $this->emergency;
}
public function getId(): ?int
{
return $this->id;
}
public function getLocation(): ?Location
{
return $this->location;
}
public function getPerson(): ?Person
{
return $this->person;
}
public function getPersons(): Collection
@@ -430,13 +328,16 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
{
if (null !== $this->accompanyingPeriod) {
$personsAssociated = [];
foreach ($this->accompanyingPeriod->getParticipations() as $participation) {
if ($this->persons->contains($participation->getPerson())) {
$personsAssociated[] = $participation->getPerson();
}
}
return $personsAssociated;
}
return [];
}
@@ -444,28 +345,103 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
{
if (null !== $this->accompanyingPeriod) {
$personsNotAssociated = [];
foreach ($this->persons as $person) {
if (!in_array($person, $this->getPersonsAssociated())) {
$personsNotAssociated[] = $person;
$personsNotAssociated[] = $person;
}
}
return $personsNotAssociated;
}
return [];
}
public function setPersons(?Collection $persons): self
public function getReasons(): Collection
{
$this->persons = $persons;
return $this->reasons;
}
public function getScope(): ?Scope
{
return $this->scope;
}
public function getSentReceived(): string
{
return $this->sentReceived;
}
public function getSocialActions(): Collection
{
return $this->socialActions;
}
public function getSocialIssues(): Collection
{
return $this->socialIssues;
}
public function getThirdParties(): Collection
{
return $this->thirdParties;
}
public function getTravelTime(): ?DateTime
{
return $this->travelTime;
}
/**
* @deprecated
*/
public function getType(): ActivityType
{
return $this->activityType;
}
public function getUser(): User
{
return $this->user;
}
public function getUsers(): Collection
{
return $this->users;
}
public function isEmergency(): bool
{
return $this->getEmergency();
}
public function removeDocument(Document $document): void
{
$this->documents->removeElement($document);
}
public function removePerson(Person $person): void
{
$this->persons->removeElement($person);
}
public function removeReason(ActivityReason $reason): void
{
$this->reasons->removeElement($reason);
}
public function removeSocialAction(SocialAction $socialAction): self
{
$this->socialActions->removeElement($socialAction);
return $this;
}
public function addThirdParty(?ThirdParty $thirdParty): self
public function removeSocialIssue(SocialIssue $socialIssue): self
{
if (null !== $thirdParty) {
$this->thirdParties[] = $thirdParty;
}
$this->socialIssues->removeElement($socialIssue);
return $this;
}
@@ -474,33 +450,44 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
$this->thirdParties->removeElement($thirdParty);
}
public function getThirdParties(): Collection
public function removeUser(User $user): void
{
return $this->thirdParties;
$this->users->removeElement($user);
}
public function setThirdParties(?Collection $thirdParties): self
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
{
$this->thirdParties = $thirdParties;
$this->accompanyingPeriod = $accompanyingPeriod;
return $this;
}
public function addDocument(Document $document): self
public function setActivityType(ActivityType $activityType): self
{
$this->documents[] = $document;
$this->activityType = $activityType;
return $this;
}
public function removeDocument(Document $document): void
public function setAttendee(ActivityPresence $attendee): self
{
$this->documents->removeElement($document);
$this->attendee = $attendee;
return $this;
}
public function getDocuments(): Collection
public function setComment(CommentEmbeddable $comment): self
{
return $this->documents;
$this->comment = $comment;
return $this;
}
public function setDate(DateTime $date): self
{
$this->date = $date;
return $this;
}
public function setDocuments(Collection $documents): self
@@ -510,41 +497,13 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
return $this;
}
public function addUser(?User $user): self
public function setDurationTime(?DateTime $durationTime): self
{
if (null !== $user) {
$this->users[] = $user;
}
return $this;
}
public function removeUser(User $user): void
{
$this->users->removeElement($user);
}
public function getUsers(): Collection
{
return $this->users;
}
public function setUsers(?Collection $users): self
{
$this->users = $users;
$this->durationTime = $durationTime;
return $this;
}
public function isEmergency(): bool
{
return $this->getEmergency();
}
public function getEmergency(): bool
{
return $this->emergency;
}
public function setEmergency(bool $emergency): self
{
$this->emergency = $emergency;
@@ -552,9 +511,39 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
return $this;
}
public function getSentReceived(): string
public function setLocation(?Location $location): Activity
{
return $this->sentReceived;
$this->location = $location;
return $this;
}
public function setPerson(?Person $person): self
{
$this->person = $person;
return $this;
}
public function setPersons(?Collection $persons): self
{
$this->persons = $persons;
return $this;
}
public function setReasons(?ArrayCollection $reasons): self
{
$this->reasons = $reasons;
return $this;
}
public function setScope(Scope $scope): self
{
$this->scope = $scope;
return $this;
}
public function setSentReceived(?string $sentReceived): self
@@ -564,21 +553,41 @@ class Activity implements HasCenterInterface, HasScopeInterface, AccompanyingPer
return $this;
}
/**
* @return Location|null
*/
public function getLocation(): ?Location
public function setThirdParties(?Collection $thirdParties): self
{
return $this->location;
$this->thirdParties = $thirdParties;
return $this;
}
public function setTravelTime(DateTime $travelTime): self
{
$this->travelTime = $travelTime;
return $this;
}
/**
* @param Location|null $location
* @return Activity
* @deprecated
*/
public function setLocation(?Location $location): Activity
public function setType(ActivityType $activityType): self
{
$this->location = $location;
$this->activityType = $activityType;
return $this;
}
public function setUser(UserInterface $user): self
{
$this->user = $user;
return $this;
}
public function setUsers(?Collection $users): self
{
$this->users = $users;
return $this;
}
}

View File

@@ -1,21 +1,10 @@
<?php
/*
/**
* Chill is a software for social workers
*
* Copyright (C) 2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* 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/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Entity;
@@ -23,15 +12,19 @@ namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Class ActivityPresence
* Class ActivityPresence.
*
* @package Chill\ActivityBundle\Entity
* @ORM\Entity()
* @ORM\Entity
* @ORM\Table(name="activitytpresence")
* @ORM\HasLifecycleCallbacks()
* @ORM\HasLifecycleCallbacks
*/
class ActivityPresence
{
/**
* @ORM\Column(type="boolean")
*/
private bool $active = true;
/**
* @ORM\Id
* @ORM\Column(name="id", type="integer")
@@ -44,28 +37,6 @@ class ActivityPresence
*/
private array $name = [];
/**
* @ORM\Column(type="boolean")
*/
private bool $active = true;
public function getId(): int
{
return $this->id;
}
public function setName(array $name): self
{
$this->name = $name;
return $this;
}
public function getName(): array
{
return $this->name;
}
/**
* Get active
* return true if the category type is active.
@@ -75,9 +46,19 @@ class ActivityPresence
return $this->active;
}
public function getId(): int
{
return $this->id;
}
public function getName(): array
{
return $this->name;
}
/**
* Is active
* return true if the category type is active
* return true if the category type is active.
*/
public function isActive(): bool
{
@@ -86,7 +67,7 @@ class ActivityPresence
/**
* Set active
* set to true if the category type is active
* set to true if the category type is active.
*/
public function setActive(bool $active): self
{
@@ -94,4 +75,11 @@ class ActivityPresence
return $this;
}
public function setName(array $name): self
{
$this->name = $name;
return $this;
}
}

View File

@@ -1,40 +1,41 @@
<?php
/*
/**
* Chill is a software for social workers
*
* Copyright (C) 2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* 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/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
/**
* Class ActivityReason
* Class ActivityReason.
*
* @package Chill\ActivityBundle\Entity
* @ORM\Entity()
* @ORM\Entity
* @ORM\Table(name="activityreason")
* @ORM\HasLifecycleCallbacks()
* @ORM\HasLifecycleCallbacks
*/
class ActivityReason
{
/**
* @var integer
* @var bool
* @ORM\Column(type="boolean")
*/
private $active = true;
/**
* @var ActivityReasonCategory
* @ORM\ManyToOne(
* targetEntity="Chill\ActivityBundle\Entity\ActivityReasonCategory",
* inversedBy="reasons")
*/
private $category;
/**
* @var int
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
@@ -49,86 +50,17 @@ class ActivityReason
private $name;
/**
* @var ActivityReasonCategory
* @ORM\ManyToOne(
* targetEntity="Chill\ActivityBundle\Entity\ActivityReasonCategory",
* inversedBy="reasons")
*/
private $category;
/**
* @var boolean
* @ORM\Column(type="boolean")
*/
private $active = true;
/**
* Get id
* Get active.
*
* @return integer
* @return bool
*/
public function getId()
public function getActive()
{
return $this->id;
return $this->active;
}
/**
* Set name
*
* @param array $name
* @return ActivityReason
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return array | string
*/
public function getName($locale = null)
{
if ($locale) {
if (isset($this->name[$locale])) {
return $this->name[$locale];
} else {
foreach ($this->name as $name) {
if (!empty($name)) {
return $name;
}
}
}
return '';
} else {
return $this->name;
}
}
/**
* Set category of the reason. If you set to the reason an inactive
* category, the reason will become inactive
*
* @param ActivityReasonCategory $category
* @return ActivityReason
*/
public function setCategory(ActivityReasonCategory $category)
{
if($this->category !== $category && ! $category->getActive()) {
$this->setActive(False);
}
$this->category = $category;
return $this;
}
/**
* Get category
* Get category.
*
* @return ActivityReasonCategory
*/
@@ -138,9 +70,46 @@ class ActivityReason
}
/**
* Set active
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Get name.
*
* @param mixed|null $locale
*
* @return array | string
*/
public function getName($locale = null)
{
if ($locale) {
if (isset($this->name[$locale])) {
return $this->name[$locale];
}
foreach ($this->name as $name) {
if (!empty($name)) {
return $name;
}
}
return '';
}
return $this->name;
}
/**
* Set active.
*
* @param bool $active
*
* @param boolean $active
* @return ActivityReason
*/
public function setActive($active)
@@ -151,13 +120,33 @@ class ActivityReason
}
/**
* Get active
* Set category of the reason. If you set to the reason an inactive
* category, the reason will become inactive.
*
* @return boolean
* @return ActivityReason
*/
public function getActive()
public function setCategory(ActivityReasonCategory $category)
{
return $this->active;
if ($this->category !== $category && !$category->getActive()) {
$this->setActive(false);
}
$this->category = $category;
return $this;
}
/**
* Set name.
*
* @param array $name
*
* @return ActivityReason
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
}

View File

@@ -1,39 +1,34 @@
<?php
/*
* Copyright (C) 2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
/**
* Chill is a software for social workers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* 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/>.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Class ActivityReasonCategory
* Class ActivityReasonCategory.
*
* @package Chill\ActivityBundle\Entity
* @ORM\Entity()
* @ORM\Entity
* @ORM\Table(name="activityreasoncategory")
* @ORM\HasLifecycleCallbacks()
* @ORM\HasLifecycleCallbacks
*/
class ActivityReasonCategory
{
/**
* @var integer
* @var bool
* @ORM\Column(type="boolean")
*/
private $active = true;
/**
* @var int
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
@@ -48,17 +43,12 @@ class ActivityReasonCategory
private $name;
/**
* @var boolean
* @ORM\Column(type="boolean")
*/
private $active = true;
/**
* Array of ActivityReason
* Array of ActivityReason.
*
* @var ArrayCollection
* @ORM\OneToMany(
* targetEntity="Chill\ActivityBundle\Entity\ActivityReason",
* mappedBy="category")
* mappedBy="category")
*/
private $reasons;
@@ -75,13 +65,23 @@ class ActivityReasonCategory
*/
public function __toString()
{
return 'ActivityReasonCategory('.$this->getName('x').')';
return 'ActivityReasonCategory(' . $this->getName('x') . ')';
}
/**
* Get id
* Get active.
*
* @return integer
* @return bool
*/
public function getActive()
{
return $this->active;
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
@@ -89,20 +89,9 @@ class ActivityReasonCategory
}
/**
* Set name
* Get name.
*
* @param array $name
* @return ActivityReasonCategory
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
* @param mixed|null $locale
*
* @return array
*/
@@ -111,30 +100,32 @@ class ActivityReasonCategory
if ($locale) {
if (isset($this->name[$locale])) {
return $this->name[$locale];
} else {
foreach ($this->name as $name) {
if (!empty($name)) {
return $name;
}
}
foreach ($this->name as $name) {
if (!empty($name)) {
return $name;
}
}
return '';
} else {
return $this->name;
}
return $this->name;
}
/**
* Declare a category as active (or not). When a category is set
* as unactive, all the reason have this entity as category is also
* set as unactive
* set as unactive.
*
* @param bool $active
*
* @param boolean $active
* @return ActivityReasonCategory
*/
public function setActive($active)
{
if($this->active !== $active && !$active) {
if ($this->active !== $active && !$active) {
foreach ($this->reasons as $reason) {
$reason->setActive($active);
}
@@ -146,13 +137,16 @@ class ActivityReasonCategory
}
/**
* Get active
* Set name.
*
* @return boolean
* @param array $name
*
* @return ActivityReasonCategory
*/
public function getActive()
public function setName($name)
{
return $this->active;
$this->name = $name;
return $this;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,12 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\ActivityBundle\Entity;
@@ -7,12 +14,17 @@ namespace Chill\ActivityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @ORM\Entity
* @ORM\Table(name="activitytypecategory")
* @ORM\HasLifecycleCallbacks()
* @ORM\HasLifecycleCallbacks
*/
class ActivityTypeCategory
{
/**
* @ORM\Column(type="boolean")
*/
private bool $active = true;
/**
* @ORM\Id
* @ORM\Column(name="id", type="integer")
@@ -26,38 +38,10 @@ class ActivityTypeCategory
private array $name = [];
/**
* @ORM\Column(type="boolean")
*/
private bool $active = true;
/**
* @ORM\Column(type="float", options={"default"="0.0"})
* @ORM\Column(type="float", options={"default": "0.0"})
*/
private float $ordering = 0.0;
public function getId(): ?int
{
return $this->id;
}
/**
* Set name
*/
public function setName(array $name): self
{
$this->name = $name;
return $this;
}
/**
* Get name
*/
public function getName(): array
{
return $this->name;
}
/**
* Get active
* return true if the category type is active.
@@ -67,9 +51,27 @@ class ActivityTypeCategory
return $this->active;
}
public function getId(): ?int
{
return $this->id;
}
/**
* Get name.
*/
public function getName(): array
{
return $this->name;
}
public function getOrdering(): float
{
return $this->ordering;
}
/**
* Is active
* return true if the category type is active
* return true if the category type is active.
*/
public function isActive(): bool
{
@@ -78,7 +80,7 @@ class ActivityTypeCategory
/**
* Set active
* set to true if the category type is active
* set to true if the category type is active.
*/
public function setActive(bool $active): self
{
@@ -87,9 +89,14 @@ class ActivityTypeCategory
return $this;
}
public function getOrdering(): float
/**
* Set name.
*/
public function setName(array $name): self
{
return $this->ordering;
$this->name = $name;
return $this;
}
public function setOrdering(float $ordering): self