mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
first impl
This commit is contained in:
parent
6bd7a0105d
commit
6a62b46dec
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Doctrine\Model;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
|
||||||
|
interface TrackCreationInterface
|
||||||
|
{
|
||||||
|
public function setCreatedBy(User $user): self;
|
||||||
|
|
||||||
|
public function setCreatedAt(\DateTimeInterface $datetime): self;
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Doctrine\Model;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
|
||||||
|
interface TrackUpdateInterface
|
||||||
|
{
|
||||||
|
public function setUpdatedBy(User $user): self;
|
||||||
|
|
||||||
|
public function setUpdatedAt(\DateTimeInterface $datetime): self;
|
||||||
|
}
|
@ -9,6 +9,12 @@ div.chill_address {
|
|||||||
margin: 0 0 0 1.5em;
|
margin: 0 0 0 1.5em;
|
||||||
text-indent: -1.5em;
|
text-indent: -1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.chill_address_address--multiline {
|
||||||
|
p {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,11 @@ ul.record_actions li {
|
|||||||
ul.record_actions, ul.record_actions_column {
|
ul.record_actions, ul.record_actions_column {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
|
|
||||||
|
&.record_actions--left {
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
padding: 0.5em 0;
|
padding: 0.5em 0;
|
||||||
flex-wrap: wrap-reverse;
|
flex-wrap: wrap-reverse;
|
||||||
|
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
<div class="chill_address">
|
||||||
|
{% if options['has_no_address'] == true and address.isNoAddress == true %}
|
||||||
|
<div class="chill_address_is_noaddress">{{ 'address.consider homeless'|trans }}</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="chill_address_address {% if options['multiline'] %}chill_address_address--multiline{% endif %}">
|
||||||
|
{% if address.street is not empty %}<p class="street street1">{{ address.street }}</p>{% endif %}
|
||||||
|
{% if address.streetNumber is not empty %}<p class="street street2">{{ address.streetNumber }}</p>{% endif %}
|
||||||
|
{% if address.postCode is not empty %}
|
||||||
|
<p class="postalCode"><span class="code">{{ address.postCode.code }}</span> <span class="name">{{ address.postCode.name }}</span></p>
|
||||||
|
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{%- if options['with_valid_from'] == true -%}
|
||||||
|
<span class="address_since">{{ 'Since %date%'|trans( { '%date%' : address.validFrom|format_date('long') } ) }}</span>
|
||||||
|
{%- endif -%}
|
||||||
|
</div>
|
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Templating\Entity;
|
||||||
|
|
||||||
|
use Symfony\Component\Templating\EngineInterface;
|
||||||
|
use Chill\MainBundle\Entity\Address;
|
||||||
|
|
||||||
|
class AddressRender implements ChillEntityRenderInterface
|
||||||
|
{
|
||||||
|
private EngineInterface $templating;
|
||||||
|
|
||||||
|
public const DEFAULT_OPTIONS = [
|
||||||
|
'with_valid_from' => true,
|
||||||
|
'has_no_address' => false,
|
||||||
|
'multiline' => true,
|
||||||
|
];
|
||||||
|
|
||||||
|
public function __construct(EngineInterface $templating)
|
||||||
|
{
|
||||||
|
$this->templating = $templating;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function supports($entity, array $options): bool
|
||||||
|
{
|
||||||
|
return $entity instanceof Address;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Address addr
|
||||||
|
*/
|
||||||
|
public function renderString($addr, array $options): string
|
||||||
|
{
|
||||||
|
$lines = [];
|
||||||
|
if (!empty($addr->getStreet())) {
|
||||||
|
$lines[0] = $addr->getStreet();
|
||||||
|
}
|
||||||
|
if (!empty($addr->getStreetNumber())) {
|
||||||
|
$lines[0] .= ", ".$addr->getStreetNumber();
|
||||||
|
}
|
||||||
|
if (!empty($addr->getPostcode())) {
|
||||||
|
$lines[1] = \strtr("{postcode} {label}", [
|
||||||
|
'{postcode}' => $addr->getPostcode()->getCode(),
|
||||||
|
'{label}' => $addr->getPostcode()->getName()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(" - ", $lines);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @param Address addr
|
||||||
|
*/
|
||||||
|
public function renderBox($addr, array $options): string
|
||||||
|
{
|
||||||
|
$options = \array_merge(self::DEFAULT_OPTIONS, $options);
|
||||||
|
|
||||||
|
return $this->templating
|
||||||
|
->render('@ChillMain/Address/entity_render.html.twig', [
|
||||||
|
'address' => $addr,
|
||||||
|
'options' => $options
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Tests\Templating\Entity;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Country;
|
||||||
|
use Chill\MainBundle\Entity\PostalCode;
|
||||||
|
use Chill\MainBundle\Templating\Entity\AddressRender;
|
||||||
|
use Chill\MainBundle\Entity\Address;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||||
|
use Symfony\Component\Templating\EngineInterface;
|
||||||
|
|
||||||
|
class AddressRenderTest extends KernelTestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider addressDataProvider
|
||||||
|
*/
|
||||||
|
public function testRenderString(Address $addr, string $expectedString): void
|
||||||
|
{
|
||||||
|
$engine = self::$container->get(EngineInterface::class);
|
||||||
|
$renderer = new AddressRender($engine);
|
||||||
|
|
||||||
|
$this->assertEquals($expectedString, $renderer->renderString($addr, []));
|
||||||
|
return;
|
||||||
|
$this->assertIsString($renderer->renderBox($addr, []));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function addressDataProvider(): \Iterator
|
||||||
|
{
|
||||||
|
$addr = new Address();
|
||||||
|
$country = (new Country())
|
||||||
|
->setName([ "fr" => "Pays" ])
|
||||||
|
->setCountryCode("BE")
|
||||||
|
;
|
||||||
|
$postCode = new PostalCode();
|
||||||
|
$postCode->setName("Locality")
|
||||||
|
->setCode("012345")
|
||||||
|
->setCountry($country)
|
||||||
|
;
|
||||||
|
|
||||||
|
$addr->setStreet("Rue ABC")
|
||||||
|
->setStreetNumber("5")
|
||||||
|
->setPostcode($postCode)
|
||||||
|
;
|
||||||
|
|
||||||
|
yield[ $addr, "Rue ABC, 5 - 012345 Locality"];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -41,3 +41,10 @@ services:
|
|||||||
Chill\MainBundle\Templating\ChillMarkdownRenderExtension:
|
Chill\MainBundle\Templating\ChillMarkdownRenderExtension:
|
||||||
tags:
|
tags:
|
||||||
- { name: twig.extension }
|
- { name: twig.extension }
|
||||||
|
|
||||||
|
Chill\MainBundle\Templating\Entity\AddressRender:
|
||||||
|
arguments:
|
||||||
|
- '@Symfony\Component\Templating\EngineInterface'
|
||||||
|
tags:
|
||||||
|
- { name: 'chill.render_entity' }
|
||||||
|
|
||||||
|
@ -22,25 +22,34 @@
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Entity;
|
namespace Chill\PersonBundle\Entity;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||||
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
|
||||||
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
|
use DateTimeInterface;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccompanyingPeriod Class
|
* AccompanyingPeriod Class
|
||||||
*
|
*
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="chill_person_accompanying_period")
|
* @ORM\Table(name="chill_person_accompanying_period")
|
||||||
|
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||||
|
* "accompanying_period"=AccompanyingPeriod::class
|
||||||
|
* })
|
||||||
*/
|
*/
|
||||||
class AccompanyingPeriod
|
class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Mark an accompanying period as "occasional"
|
* Mark an accompanying period as "occasional"
|
||||||
@ -80,6 +89,7 @@ class AccompanyingPeriod
|
|||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
@ -87,6 +97,7 @@ class AccompanyingPeriod
|
|||||||
* @var \DateTime
|
* @var \DateTime
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="date")
|
* @ORM\Column(type="date")
|
||||||
|
* @Groups({"read", "write"})
|
||||||
*/
|
*/
|
||||||
private $openingDate;
|
private $openingDate;
|
||||||
|
|
||||||
@ -94,6 +105,7 @@ class AccompanyingPeriod
|
|||||||
* @var \DateTime
|
* @var \DateTime
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="date", nullable=true)
|
* @ORM\Column(type="date", nullable=true)
|
||||||
|
* @Groups({"read", "write"})
|
||||||
*/
|
*/
|
||||||
private $closingDate = null;
|
private $closingDate = null;
|
||||||
|
|
||||||
@ -101,6 +113,7 @@ class AccompanyingPeriod
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="text")
|
* @ORM\Column(type="text")
|
||||||
|
* @Groups({"read", "write"})
|
||||||
*/
|
*/
|
||||||
private $remark = '';
|
private $remark = '';
|
||||||
|
|
||||||
@ -108,17 +121,28 @@ class AccompanyingPeriod
|
|||||||
* @var Collection
|
* @var Collection
|
||||||
*
|
*
|
||||||
* @ORM\OneToMany(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Comment",
|
* @ORM\OneToMany(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Comment",
|
||||||
* mappedBy="accompanyingPeriod"
|
* mappedBy="accompanyingPeriod",
|
||||||
|
* cascade={"persist", "remove"},
|
||||||
|
* orphanRemoval=true
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
private $comments;
|
private $comments;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(
|
||||||
|
* targetEntity=Comment::class
|
||||||
|
* )
|
||||||
|
* @Groups({"read"})
|
||||||
|
*/
|
||||||
|
private ?Comment $initialComment = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection
|
* @var Collection
|
||||||
*
|
*
|
||||||
* @ORM\OneToMany(targetEntity=AccompanyingPeriodParticipation::class,
|
* @ORM\OneToMany(targetEntity=AccompanyingPeriodParticipation::class,
|
||||||
* mappedBy="accompanyingPeriod",
|
* mappedBy="accompanyingPeriod",
|
||||||
* cascade={"persist", "refresh", "remove", "merge", "detach"})
|
* cascade={"persist", "refresh", "remove", "merge", "detach"})
|
||||||
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $participations;
|
private $participations;
|
||||||
|
|
||||||
@ -128,36 +152,42 @@ class AccompanyingPeriod
|
|||||||
* @ORM\ManyToOne(
|
* @ORM\ManyToOne(
|
||||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive")
|
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive")
|
||||||
* @ORM\JoinColumn(nullable=true)
|
* @ORM\JoinColumn(nullable=true)
|
||||||
|
* @Groups({"read", "write"})
|
||||||
*/
|
*/
|
||||||
private $closingMotive = null;
|
private $closingMotive = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=User::class)
|
* @ORM\ManyToOne(targetEntity=User::class)
|
||||||
* @ORM\JoinColumn(nullable=true)
|
* @ORM\JoinColumn(nullable=true)
|
||||||
|
* @Groups({"read", "write"})
|
||||||
*/
|
*/
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=User::class)
|
* @ORM\ManyToOne(targetEntity=User::class)
|
||||||
* @ORM\JoinColumn(nullable=true)
|
* @ORM\JoinColumn(nullable=true)
|
||||||
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $createdBy;
|
private $createdBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
* @ORM\Column(type="string", length=32, nullable=true)
|
* @ORM\Column(type="string", length=32, nullable=true)
|
||||||
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $step = self::STEP_DRAFT;
|
private $step = self::STEP_DRAFT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=Origin::class)
|
* @ORM\ManyToOne(targetEntity=Origin::class)
|
||||||
* @ORM\JoinColumn(nullable=true)
|
* @ORM\JoinColumn(nullable=true)
|
||||||
|
* @Groups({"read", "write"})
|
||||||
*/
|
*/
|
||||||
private $origin;
|
private $origin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
* @ORM\Column(type="string", nullable=true)
|
* @ORM\Column(type="string", nullable=true)
|
||||||
|
* @Groups({"read", "write"})
|
||||||
*/
|
*/
|
||||||
private $intensity;
|
private $intensity;
|
||||||
|
|
||||||
@ -172,6 +202,7 @@ class AccompanyingPeriod
|
|||||||
* joinColumns={@ORM\JoinColumn(name="accompanying_period_id", referencedColumnName="id")},
|
* joinColumns={@ORM\JoinColumn(name="accompanying_period_id", referencedColumnName="id")},
|
||||||
* inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")}
|
* inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")}
|
||||||
* )
|
* )
|
||||||
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $scopes;
|
private $scopes;
|
||||||
|
|
||||||
@ -189,19 +220,22 @@ class AccompanyingPeriod
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
* @ORM\Column(type="boolean")
|
* @ORM\Column(type="boolean", options={"default": false} )
|
||||||
|
* @Groups({"read", "write"})
|
||||||
*/
|
*/
|
||||||
private $requestorAnonymous = false;
|
private $requestorAnonymous = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
* @ORM\Column(type="boolean")
|
* @ORM\Column(type="boolean", options={"default": false} )
|
||||||
|
* @Groups({"read", "write"})
|
||||||
*/
|
*/
|
||||||
private $emergency = false;
|
private $emergency = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
* @ORM\Column(type="boolean")
|
* @ORM\Column(type="boolean", options={"default": false} )
|
||||||
|
* @Groups({"read", "write"})
|
||||||
*/
|
*/
|
||||||
private $confidential = false;
|
private $confidential = false;
|
||||||
|
|
||||||
@ -210,21 +244,54 @@ class AccompanyingPeriod
|
|||||||
*
|
*
|
||||||
* @ORM\OneToMany(
|
* @ORM\OneToMany(
|
||||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Resource",
|
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Resource",
|
||||||
* mappedBy="accompanyingPeriod"
|
* mappedBy="accompanyingPeriod",
|
||||||
|
* cascade={"persist", "remove"},
|
||||||
|
* orphanRemoval=true
|
||||||
* )
|
* )
|
||||||
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $resources;
|
private $resources;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToMany(
|
||||||
|
* targetEntity=SocialIssue::class
|
||||||
|
* )
|
||||||
|
* @ORM\JoinTable(
|
||||||
|
* name="chill_person_accompanying_period_social_issues"
|
||||||
|
* )
|
||||||
|
* @Groups({"read"})
|
||||||
|
*/
|
||||||
|
private Collection $socialIssues;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
|
||||||
|
*/
|
||||||
|
private \DateTimeInterface $createdAt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(
|
||||||
|
* targetEntity=User::class
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
private User $updatedBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
|
||||||
|
*/
|
||||||
|
private \DateTimeInterface $updatedAt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccompanyingPeriod constructor.
|
* AccompanyingPeriod constructor.
|
||||||
*
|
*
|
||||||
* @param \DateTime $dateOpening
|
* @param \DateTime $dateOpening
|
||||||
* @uses AccompanyingPeriod::setClosingDate()
|
* @uses AccompanyingPeriod::setClosingDate()
|
||||||
*/
|
*/
|
||||||
public function __construct(\DateTime $dateOpening) {
|
public function __construct(\DateTime $dateOpening = null) {
|
||||||
$this->setOpeningDate($dateOpening);
|
$this->setOpeningDate($dateOpening ?? new \DateTime('now'));
|
||||||
$this->participations = new ArrayCollection();
|
$this->participations = new ArrayCollection();
|
||||||
$this->scopes = new ArrayCollection();
|
$this->scopes = new ArrayCollection();
|
||||||
|
$this->socialIssues = new ArrayCollection();
|
||||||
|
$this->comments = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -318,23 +385,55 @@ class AccompanyingPeriod
|
|||||||
return $this->remark;
|
return $this->remark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Groups({"read"})
|
||||||
|
*/
|
||||||
public function getComments(): Collection
|
public function getComments(): Collection
|
||||||
{
|
{
|
||||||
return $this->comments;
|
return $this->comments->filter(function (Comment $c) {
|
||||||
|
return $c !== $this->initialComment;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addComment(Comment $comment): self
|
public function addComment(Comment $comment): self
|
||||||
{
|
{
|
||||||
$this->comments[] = $comment;
|
$this->comments[] = $comment;
|
||||||
|
$comment->setAccompanyingPeriod($this);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeComment(Comment $comment): void
|
public function removeComment(Comment $comment): void
|
||||||
{
|
{
|
||||||
|
$comment->setAccompanyingPeriod(null);
|
||||||
$this->comments->removeElement($comment);
|
$this->comments->removeElement($comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Groups({"write"})
|
||||||
|
*/
|
||||||
|
public function setInitialComment(?Comment $comment = null): self
|
||||||
|
{
|
||||||
|
if (NULL !== $this->initialComment) {
|
||||||
|
$this->removeComment($this->initialComment);
|
||||||
|
}
|
||||||
|
if ($comment instanceof Comment) {
|
||||||
|
$this->addComment($comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->initialComment = $comment;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Groups({"read"})
|
||||||
|
*/
|
||||||
|
public function getInitialComment(): ?Comment
|
||||||
|
{
|
||||||
|
return $this->initialComment;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Participations Collection
|
* Get Participations Collection
|
||||||
*/
|
*/
|
||||||
@ -515,9 +614,9 @@ class AccompanyingPeriod
|
|||||||
return $this->requestorPerson;
|
return $this->requestorPerson;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRequestorPerson(Person $requestorPerson): self
|
private function setRequestorPerson(Person $requestorPerson = null): self
|
||||||
{
|
{
|
||||||
$this->requestorPerson = ($this->requestorThirdParty === null) ? $requestorPerson : null;
|
$this->requestorPerson = $requestorPerson;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -527,21 +626,53 @@ class AccompanyingPeriod
|
|||||||
return $this->requestorThirdParty;
|
return $this->requestorThirdParty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRequestorThirdParty(ThirdParty $requestorThirdParty): self
|
private function setRequestorThirdParty(ThirdParty $requestorThirdParty = null): self
|
||||||
{
|
{
|
||||||
$this->requestorThirdParty = ($this->requestorPerson === null) ? $requestorThirdParty : null;
|
$this->requestorThirdParty = $requestorThirdParty;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Person|ThirdParty
|
* @return Person|ThirdParty
|
||||||
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
public function getRequestor()
|
public function getRequestor()
|
||||||
{
|
{
|
||||||
return $this->requestorPerson ?? $this->requestorThirdParty;
|
return $this->requestorPerson ?? $this->requestorThirdParty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a requestor
|
||||||
|
*
|
||||||
|
* The requestor is either an instance of ThirdParty, or an
|
||||||
|
* instance of Person
|
||||||
|
*
|
||||||
|
* @param $requestor Person|ThirdParty
|
||||||
|
* @return self
|
||||||
|
* @throw UnexpectedValueException if the requestor is not a Person or ThirdParty
|
||||||
|
* @Groups({"write"})
|
||||||
|
*/
|
||||||
|
public function setRequestor($requestor): self
|
||||||
|
{
|
||||||
|
if ($requestor instanceof Person) {
|
||||||
|
$this->setRequestorThirdParty(NULL);
|
||||||
|
$this->setRequestorPerson($requestor);
|
||||||
|
} elseif ($requestor instanceof ThirdParty) {
|
||||||
|
$this->setRequestorThirdParty($requestor);
|
||||||
|
$this->setRequestorPerson(NULL);
|
||||||
|
} elseif (NULL === $requestor) {
|
||||||
|
$this->setRequestorPerson(NULL);
|
||||||
|
$this->setRequestorThirdParty(NULL);
|
||||||
|
} else {
|
||||||
|
throw new \UnexpectedValueException("requestor is not an instance of Person or ThirdParty");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function isRequestorAnonymous(): bool
|
public function isRequestorAnonymous(): bool
|
||||||
{
|
{
|
||||||
return $this->requestorAnonymous;
|
return $this->requestorAnonymous;
|
||||||
@ -638,6 +769,7 @@ class AccompanyingPeriod
|
|||||||
|
|
||||||
public function addResource(Resource $resource): self
|
public function addResource(Resource $resource): self
|
||||||
{
|
{
|
||||||
|
$resource->setAccompanyingPeriod($this);
|
||||||
$this->resources[] = $resource;
|
$this->resources[] = $resource;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -645,9 +777,27 @@ class AccompanyingPeriod
|
|||||||
|
|
||||||
public function removeResource(Resource $resource): void
|
public function removeResource(Resource $resource): void
|
||||||
{
|
{
|
||||||
|
$resource->setAccompanyingPeriod(null);
|
||||||
$this->resources->removeElement($resource);
|
$this->resources->removeElement($resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSocialIssues(): Collection
|
||||||
|
{
|
||||||
|
return $this->socialIssues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addSocialIssue(SocialIssue $socialIssue): self
|
||||||
|
{
|
||||||
|
$this->socialIssues[] = $socialIssue;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeSocialIssue(SocialIssue $socialIssue): void
|
||||||
|
{
|
||||||
|
$this->socialIssues->removeElement($socialIssue);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all persons which are participating to this course
|
* Get a list of all persons which are participating to this course
|
||||||
*/
|
*/
|
||||||
@ -659,4 +809,25 @@ class AccompanyingPeriod
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setCreatedAt(\DateTimeInterface $datetime): self
|
||||||
|
{
|
||||||
|
$this->createdAt = $datetime;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUpdatedBy(User $user): self
|
||||||
|
{
|
||||||
|
$this->updatedBy = $user;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUpdatedAt(\DateTimeInterface $datetime): self
|
||||||
|
{
|
||||||
|
$this->updatedAt = $datetime;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -417,6 +417,31 @@ class Person implements HasCenterInterface
|
|||||||
return $this->accompanyingPeriodParticipations;
|
return $this->accompanyingPeriodParticipations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a collection of participation, where the participation
|
||||||
|
* is still opened, not a draft, and the period is still opened
|
||||||
|
*/
|
||||||
|
public function getOpenedParticipations(): Collection
|
||||||
|
{
|
||||||
|
// create a criteria for filtering easily
|
||||||
|
$criteria = Criteria::create();
|
||||||
|
$criteria
|
||||||
|
->andWhere(Criteria::expr()->eq('endDate', NULL))
|
||||||
|
->orWhere(Criteria::expr()->gt('endDate', new \DateTime('now')))
|
||||||
|
;
|
||||||
|
|
||||||
|
return $this->getAccompanyingPeriodParticipations()
|
||||||
|
->matching($criteria)
|
||||||
|
->filter(function (AccompanyingPeriodParticipation $app) {
|
||||||
|
$period = $app->getAccompanyingPeriod();
|
||||||
|
return (
|
||||||
|
NULL === $period->getClosingDate()
|
||||||
|
|| new \DateTime('now') < $period->getClosingDate()
|
||||||
|
)
|
||||||
|
&& AccompanyingPeriod::STEP_DRAFT !== $period->getStep();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the accompanying periods of a give person with the chronological order.
|
* Get the accompanying periods of a give person with the chronological order.
|
||||||
*/
|
*/
|
||||||
|
@ -1 +1,2 @@
|
|||||||
require('./sass/person.scss');
|
require('./sass/person.scss');
|
||||||
|
require('./sass/person_with_period.scss');
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
require('./phone-alt-solid.svg');
|
require('./phone-alt-solid.svg');
|
||||||
require('./mobile-alt-solid.svg');
|
require('./mobile-alt-solid.svg');
|
||||||
require('./person_by_phonenumber.scss');
|
require('./person_by_phonenumber.scss');
|
||||||
|
require('./person_with_period.scss');
|
||||||
|
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
.person-list--with-period {
|
||||||
|
.person-list--with-period__item {
|
||||||
|
margin-bottom: 0;
|
||||||
|
padding: 1em 1em 2em 1em;
|
||||||
|
&:nth-last-of-type {
|
||||||
|
padding-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:nth-of-type(odd) {
|
||||||
|
//background-color: var(--chill-light-gray);
|
||||||
|
}
|
||||||
|
&:nth-of-type(even) {
|
||||||
|
//background-color: var(--chill-dark-gray);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chill-entity__person {
|
||||||
|
.chill-entity__person__first-name,
|
||||||
|
.chill-entity__person__last-name {
|
||||||
|
font-size: 1.3em;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
& > div {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
.person-list--with-period__item__box-where {
|
||||||
|
align-self: flex-end;
|
||||||
|
margin-left: auto;
|
||||||
|
width: 33%;
|
||||||
|
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.person-list--with-period__item__periods {
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
|
li {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.person-list--with-period__item:hover {
|
||||||
|
background-color: var(--chill-llight-gray);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
<span class="chill-entity chill-entity__person">
|
||||||
|
{%- if addLink and is_granted('CHILL_PERSON_SEE', person) -%}
|
||||||
|
{%- set showLink = true -%}<a href="{{ chill_path_add_return_path('chill_person_view', { 'person_id': person.id }) }}">{%- endif -%}
|
||||||
|
<span class="chill-entity__person__first-name">{{ person.firstName }}</span>
|
||||||
|
<span class="chill-entity__person__last-name">{{ person.lastName }}</span>
|
||||||
|
{%- if addAltNames -%}
|
||||||
|
{%- for n in person.altNames -%}
|
||||||
|
{%- if loop.first -%}({% else %} {%- endif -%}
|
||||||
|
<span class="chill-entity__person__alt-name chill-entity__person__altname--{{ n.key }}">
|
||||||
|
{{ n.label }}
|
||||||
|
</span>
|
||||||
|
{%- if loop.last %}) {% endif -%}
|
||||||
|
{%- endfor -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- if showLink is defined -%}</a>{%- endif -%}</span>
|
@ -0,0 +1,3 @@
|
|||||||
|
<span class="chill-entity chill-entity__social-issue">
|
||||||
|
|
||||||
|
</span>
|
@ -0,0 +1,208 @@
|
|||||||
|
<h2>{{ title|default('Person search results')|trans }}</h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{{ '%total% persons matching the search pattern:'|transchoice( total, { '%total%' : total}) }}
|
||||||
|
<a href="{{ path('chill_main_advanced_search', { "name": search_name, "q": pattern } ) }}" class="sc-button button-small">
|
||||||
|
<i class="fa fa-search" aria-hidden="true"></i> {{ pattern }}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>{{ 'Results %start%-%end% of %total%'|trans({ '%start%' : start, '%end%': start + persons|length, '%total%' : total } ) }}</p>
|
||||||
|
|
||||||
|
<ul class="record_actions">
|
||||||
|
{% if is_granted('CHILL_PERSON_CREATE') %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_person_new') }}" class="sc-button bt-create">
|
||||||
|
{{ 'Add a person'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if search_name != "person_similarity" %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_main_advanced_search', { "name": search_name, "q": pattern } ) }}" class="sc-button bt-action">
|
||||||
|
<i class="fa fa-search" aria-hidden="true"></i> {{ 'Advanced search'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if preview == true and persons|length < total %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_main_search', { "name": search_name|default('abcd'), "q" : pattern }) }}" class="sc-button">
|
||||||
|
{{ 'See all results'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
{% if persons|length > 0 %}
|
||||||
|
|
||||||
|
<div class="person-list--with-period">
|
||||||
|
{% for person in persons %}
|
||||||
|
<div class="person-list--with-period__item">
|
||||||
|
<div>
|
||||||
|
<div class="person-list--with-period__item__box-person">
|
||||||
|
<div>
|
||||||
|
<span>{{ person|chill_entity_render_box({'addLink': true}) }}</span>
|
||||||
|
<span>{{ person.birthdate|format_date("medium") }}</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<ul class="record_actions record_actions--left">
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_person_view', { 'person_id' : person.id }) }}" class="sc-button bt-view" />
|
||||||
|
{{ 'Open person file'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_person_accompanying_period_list', { 'person_id' : person.id }) }}" class="sc-button" /><i class="fa fa-random"></i></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="person-list--with-period__item__box-where">
|
||||||
|
<span>{{ person.center }}</span>
|
||||||
|
{% if person.getLastAddress is not null %}
|
||||||
|
<span>{{ person.getLastAddress|chill_entity_render_box({'with_valid_from': false}) }}</span>
|
||||||
|
{% else %}
|
||||||
|
<span>{{ 'No address'|trans }}</span>
|
||||||
|
{% endif %}
|
||||||
|
{% if person.mobilenumber is not empty %}
|
||||||
|
<span>{{ person.mobilenumber }}</span>
|
||||||
|
{% endif %}
|
||||||
|
{% if person.phonenumber is not empty %}
|
||||||
|
<span>{{ person.phonenumber }}</span>
|
||||||
|
{% endif %}
|
||||||
|
<span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#- 'apps' is for AccompanyingPeriodParticipationS #}
|
||||||
|
{#- filter using acl -#}
|
||||||
|
{%- set apps = [] %}
|
||||||
|
{%- for app in person.openedParticipations %}
|
||||||
|
{%- if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', app.accompanyingPeriod) %}
|
||||||
|
{%- set apps = apps|merge([app]) %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
{% if apps|length > 0 %}
|
||||||
|
<ul class="person-list--with-period__item__periods">
|
||||||
|
{% for app in apps %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': app.accompanyingPeriod.id }) }}">
|
||||||
|
<i class="fa fa-random"></i>
|
||||||
|
<span>{{ 'Since %date%'|trans({'%date%': app.startDate|format_date('medium') }) }}</span>
|
||||||
|
{% if app.accompanyingPeriod.user is not null %}
|
||||||
|
<span>
|
||||||
|
{{ app.accompanyingPeriod.user|chill_entity_render_box }}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% for issue in app.accompanyingPeriod.socialIssues|slice(0,2) %}
|
||||||
|
<span>{{ issue|chill_entity_render_box }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
{% if app.accompanyingPeriod.socialIssues|length > 2 %}
|
||||||
|
<span>{{ 'and %number% other'|transchoice(app.accompanyingPeriod.socialIssues|length-2) }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="chill-red">{% trans %}Name{% endtrans %}</th>
|
||||||
|
<th class="chill-green">{% trans %}Date of birth{% endtrans %}</th>
|
||||||
|
<th class="chill-orange">{% trans %}Nationality{% endtrans %}</th>
|
||||||
|
<th> </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for person in persons %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{% set is_open = person.isOpen() %}
|
||||||
|
<a href="{{ path('chill_person_view', { person_id : person.getId }) }}" {% if chill_person.fields.accompanying_period == 'visible' %}{% if is_open %} alt="{{ 'An accompanying period is open'|trans|e('html_attr') }}"{% else %} alt="{{ 'Any accompanying periods are open'|trans|e('html_attr') }}" {% endif %}{% endif %}>
|
||||||
|
{{ person|chill_entity_render_box }}
|
||||||
|
{% apply spaceless %}
|
||||||
|
{% if chill_person.fields.accompanying_period == 'visible' %}
|
||||||
|
{% if is_open == false %}
|
||||||
|
<i class="fa fa-lock" ></i>
|
||||||
|
{% else %}
|
||||||
|
<i class="fa fa-unlock" ></i>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endapply %}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if person.birthdate is not null %}
|
||||||
|
{{ person.birthdate|format_date('long') }}
|
||||||
|
{% else %}{{ 'Unknown date of birth'|trans }}{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if person.nationality is not null %}
|
||||||
|
{{person.nationality.name | localize_translatable_string }}
|
||||||
|
{% else %}
|
||||||
|
{{ 'Without nationality'|trans }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li><a class="sc-button bt-show" href="{{ path('chill_person_view', { person_id : person.getId }) }}"></a></li>
|
||||||
|
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
|
||||||
|
<li><a class="sc-button bt-update" href="{{ path('chill_person_general_edit', { person_id : person.getId }) }}"></a></li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
#}
|
||||||
|
|
||||||
|
<ul class="record_actions">
|
||||||
|
{% if is_granted('CHILL_PERSON_CREATE') %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_person_new') }}" class="sc-button bt-create">
|
||||||
|
{{ 'Add a person'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if search_name != "person_similarity" %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_main_advanced_search', { "name": search_name, "q": pattern } ) }}" class="sc-button bt-action">
|
||||||
|
<i class="fa fa-search" aria-hidden="true"></i> {{ 'Advanced search'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if preview == true and persons|length < total %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_main_search', { "name": search_name|default('abcd'), "q" : pattern }) }}" class="sc-button">
|
||||||
|
{{ 'See all results'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_main_advanced_search', { "name": search_name, "q": pattern } ) }}" class="sc-button bt-action">
|
||||||
|
<i class="fa fa-search" aria-hidden="true"></i> {{ 'Advanced search'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if preview == false %}
|
||||||
|
{{ chill_pagination(paginator) }}
|
||||||
|
{% endif %}
|
||||||
|
|
@ -120,7 +120,7 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface,
|
|||||||
$paginator = $this->paginatorFactory->create($total);
|
$paginator = $this->paginatorFactory->create($total);
|
||||||
|
|
||||||
if ($format === 'html') {
|
if ($format === 'html') {
|
||||||
return $this->container->get('templating')->render('ChillPersonBundle:Person:list.html.twig',
|
return $this->container->get('templating')->render('@ChillPerson/Person/list_with_period.html.twig',
|
||||||
array(
|
array(
|
||||||
'persons' => $this->search($terms, $start, $limit, $options),
|
'persons' => $this->search($terms, $start, $limit, $options),
|
||||||
'pattern' => $this->recomposePattern($terms, array('nationality',
|
'pattern' => $this->recomposePattern($terms, array('nationality',
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Templating\Entity;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
|
||||||
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
|
||||||
|
class SocialIssueRender implements ChillEntityRenderInterface
|
||||||
|
{
|
||||||
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
|
public const SEPARATOR_KEY = 'default.separator';
|
||||||
|
|
||||||
|
public const DEFAULT_ARGS = [
|
||||||
|
self::SEPARATOR_KEY => ' > ',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||||
|
{
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function supports($entity, array $options): bool
|
||||||
|
{
|
||||||
|
return $entity instanceof SocialIssue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderString($socialIssue, array $options): string
|
||||||
|
{
|
||||||
|
/** @var $socialIssue SocialIssue */
|
||||||
|
$options = \array_merge(self::DEFAULT_ARGS, $options);
|
||||||
|
|
||||||
|
$str = $this->translatableStringHelper->localize($socialIssue->getTitle());
|
||||||
|
|
||||||
|
while ($socialIssue->hasParent()) {
|
||||||
|
$socialIssue = $socialIssue->getParent();
|
||||||
|
$str .= $options[self::SEPARATOR_KEY].$this->translatableStringHelper->localize(
|
||||||
|
$socialIssue->getTitle()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderBox($entity, array $options): string
|
||||||
|
{
|
||||||
|
return "renderBox not implemented for social issue";
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,21 @@
|
|||||||
services:
|
services:
|
||||||
|
Chill\PersonBundle\Templating\Entity\:
|
||||||
|
resource: '../../Templating/Entity'
|
||||||
|
tags:
|
||||||
|
- 'chill.render_entity'
|
||||||
|
|
||||||
Chill\PersonBundle\Templating\Entity\PersonRender:
|
Chill\PersonBundle\Templating\Entity\PersonRender:
|
||||||
arguments:
|
arguments:
|
||||||
$configAltNamesHelper: '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper'
|
$configAltNamesHelper: '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper'
|
||||||
tags:
|
tags:
|
||||||
- 'chill.render_entity'
|
- 'chill.render_entity'
|
||||||
|
|
||||||
Chill\PersonBundle\Templating\Entity\ClosingMotiveRender:
|
Chill\PersonBundle\Templating\Entity\ClosingMotiveRender:
|
||||||
arguments:
|
arguments:
|
||||||
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
|
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
|
||||||
|
|
||||||
|
Chill\PersonBundle\Templating\Entity\SocialIssueRender:
|
||||||
|
arguments:
|
||||||
|
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
|
||||||
tags:
|
tags:
|
||||||
- 'chill.render_entity'
|
- 'chill.render_entity'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user