Merge branch 'master' into 292_activity_acl

This commit is contained in:
2021-12-13 09:21:32 +01:00
80 changed files with 2202 additions and 927 deletions

View File

@@ -63,7 +63,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
* @var string
* @ORM\Column(name="acronym", type="string", length=64, nullable=true)
* @Assert\Length(min="2")
* @Groups({"read", "write"})
* @Groups({"read", "write", "docgen:read"})
*/
private ?string $acronym = '';
@@ -78,7 +78,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
* @ORM\ManyToOne(targetEntity="\Chill\MainBundle\Entity\Address",
* cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
* @Groups({"read", "write"})
* @Groups({"read", "write", "docgen:read"})
*/
private ?Address $address = null;
@@ -97,6 +97,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
* @ORM\JoinTable(name="chill_3party.thirdparty_category",
* joinColumns={@ORM\JoinColumn(name="thirdparty_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id")})
* @Groups({"docgen:read"})
*/
private Collection $categories;
@@ -121,6 +122,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
* @var Civility
* @ORM\ManyToOne(targetEntity=Civility::class)
* ORM\JoinColumn(name="civility", referencedColumnName="id", nullable=true)
* @Groups({"docgen:read", "read"})
*/
private ?Civility $civility = null;
@@ -132,7 +134,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(name="contact_data_anonymous", type="boolean", options={"default": false})
* @Groups({"read"})
* @Groups({"read", "docgen:read"})
*/
private bool $contactDataAnonymous = false;
@@ -150,7 +152,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Column(name="email", type="string", length=255, nullable=true)
* @Assert\Email(checkMX=false)
* @Groups({"read", "write"})
* @Groups({"read", "write", "docgen:read"})
*/
private ?string $email = null;
@@ -159,6 +161,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"read", "write", "docgen:read"})
*/
private ?int $id = null;
@@ -172,7 +175,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
* @var string
* @ORM\Column(name="name", type="string", length=255)
* @Assert\Length(min="2")
* @Groups({"read", "write"})
* @Groups({"read", "write", "docgen:read"})
*/
private ?string $name = '';
@@ -182,7 +185,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
* @var string
* @ORM\Column(name="name_company", type="string", length=255, nullable=true)
* @Assert\Length(min="3")
* @Groups({"read", "write"})
* @Groups({"read", "write", "docgen:read"})
*/
private ?string $nameCompany = '';
@@ -201,6 +204,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
* @var ThirdPartyProfession
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyProfession")
* ORM\JoinColumn(name="profession", referencedColumnName="id", nullable=true)
* @Groups({"docgen:read"})
*/
private ?ThirdPartyProfession $profession = null;
@@ -210,7 +214,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
* message="Invalid phone number: it should begin with the international prefix starting with ""+"", hold only digits and be smaller than 20 characters. Ex: +33123456789"
* )
* @PhonenumberConstraint(type="any")
* @Groups({"read", "write"})
* @Groups({"read", "write", "dogen:read"})
*/
private ?string $telephone = null;
@@ -496,7 +500,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
}
/**
* @Groups({"read"})
* @Groups({"read", "docgen:read"})
*/
public function isChild(): bool
{

View File

@@ -13,6 +13,7 @@ namespace Chill\ThirdPartyBundle\Entity;
use Chill\ThirdPartyBundle\Repository\ThirdPartyCategoryRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Table(name="chill_3party.party_category")
@@ -23,19 +24,21 @@ class ThirdPartyCategory
/**
* @ORM\Column(type="boolean")
*/
private $active = true;
private bool $active = true;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({"docgen:read"})
*/
private $id;
private ?int $id = null;
/**
* @ORM\Column(type="json")
* @Serializer\Groups({"docgen:read"})
*/
private $name = [];
private array $name = [];
public function getActive(): ?bool
{

View File

@@ -13,6 +13,7 @@ namespace Chill\ThirdPartyBundle\Entity;
use Chill\ThirdPartyBundle\Repository\ThirdPartyProfessionRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Table(name="chill_3party.party_profession")
@@ -23,19 +24,21 @@ class ThirdPartyProfession
/**
* @ORM\Column(type="boolean")
*/
private $active = true;
private bool $active = true;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({"docgen:read"})
*/
private $id;
private ?int $id = null;
/**
* @ORM\Column(type="json")
* @Serializer\Groups({"docgen:read"})
*/
private $name = [];
private array $name = [];
public function getActive(): ?bool
{

View File

@@ -51,6 +51,6 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
public function supportsNormalization($data, ?string $format = null)
{
return $data instanceof ThirdParty;
return $data instanceof ThirdParty && 'json' === $format;
}
}

View File

@@ -0,0 +1,51 @@
<?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\ThirdPartyBundle\Test\Serializer\Normalizer;
use Chill\MainBundle\Entity\Civility;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
/**
* @internal
* @coversNothing
*/
final class ThirdpartyDocGenNormalizerTest extends KernelTestCase
{
private NormalizerInterface $normalizer;
protected function setUp(): void
{
self::bootKernel();
$this->normalizer = self::$container->get(NormalizerInterface::class);
}
public function testNormalize()
{
$thirdparty = new ThirdParty();
$thirdparty
->setAcronym('ABCD')
->setName('test')
->setCivility((new Civility())->setName(['fr' => 'Monsieur'])->setAbbreviation(['fr' => 'M.']))
->setEmail('info@cl.coop')
->addTypesAndCategories('kind')
->addTypesAndCategories((new ThirdPartyCategory())->setName(['fr' => 'category']));
$actual = $this->normalizer->normalize($thirdparty, 'docgen', ['groups' => ['docgen:read']]);
var_dump($actual);
$this->assertIsArray($actual);
}
}