src/Entity/JournalScientificCouncilMember.php line 56
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM,
Doctrine\DBAL\Types\Types,
Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Serializer\Annotation\Groups,
Symfony\Component\Validator\Constraints as Assert;
use ApiPlatform\Metadata\ApiResource,
ApiPlatform\Metadata\ApiProperty,
ApiPlatform\Metadata\Get,
ApiPlatform\Metadata\GetCollection,
ApiPlatform\Metadata\Post,
ApiPlatform\Metadata\Put,
ApiPlatform\Metadata\Delete,
ApiPlatform\Metadata\ApiFilter,
ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
use App\Entity\Trait\IdTrait,
App\Entity\Trait\UuidTrait,
App\Entity\Trait\OrdStatTrait,
App\Entity\Trait\TimestampableTrait,
App\Entity\Trait\TranslatableTrait,
App\Entity\Trait\Languages\LanguageableChildTrait,
App\Entity\Interface\TranslatableInterface,
App\Entity\Interface\OrdStatableInterface,
App\Entity\Interface\LanguageableChildInterface,
App\Repository\JournalScientificCouncilMemberRepository;
use App\Filter\IriFilter;
#[ApiResource(
description: 'Journal scientific council members',
normalizationContext: ['groups' => [
'read',
'read:' . self::class,
'read:' . self::class . 'Translation',
]],
denormalizationContext: ['groups' => ['write']],
security: 'is_granted("' . Journal::class . '")',
order: ['ord' => 'desc'],
operations: [
new GetCollection(),
new Post(denormalizationContext: ['groups' => ['write', 'post']]),
new Get(),
new Put(),
new Delete(),
],
extraProperties: ['standard_put' => false],
)]
#[ApiFilter(IriFilter::class, properties: ['parent'])]
#[ApiFilter(OrderFilter::class, properties: ['ord'])]
#[ORM\Entity(repositoryClass: JournalScientificCouncilMemberRepository::class)]
class JournalScientificCouncilMember implements
TranslatableInterface,
OrdStatableInterface,
LanguageableChildInterface
{
use IdTrait,
UuidTrait,
OrdStatTrait,
TimestampableTrait,
TranslatableTrait,
LanguageableChildTrait;
#[ApiProperty(description: 'Parent', readableLink: false, writableLink: false)]
#[Groups(['read', 'post'])]
#[Assert\NotNull]
#[ORM\ManyToOne(targetEntity: Journal::class, inversedBy: 'scientificCouncilMembers')]
#[ORM\JoinColumn(onDelete: 'cascade', nullable: false)]
private Journal $parent;
#[ApiProperty(description: 'Name')]
#[Groups(['read', 'write'])]
#[Assert\NotBlank]
#[ORM\Column(type: Types::STRING, length: 255)]
private string $name;
#[ApiProperty(description: 'Surname')]
#[Groups(['read', 'write'])]
#[Assert\NotBlank]
#[ORM\Column(type: Types::STRING, length: 255)]
private string $surname;
#[ApiProperty(description: 'Orcid')]
#[Groups(['read:' . self::class, 'write'])]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private ?string $orcid = null;
#[ApiProperty(description: 'Affiliation', writableLink: false)]
#[Groups(['read:' . self::class, 'write'])]
#[Assert\Expression(
expression: '!value || value.getDepth() === 0',
message: 'Cannot assign affiliation which is not an institution.'
)]
#[ORM\ManyToOne(targetEntity: Affiliation::class)]
#[ORM\JoinColumn(onDelete: 'set null')]
private ?Affiliation $affiliation = null;
public function __construct(Journal $parent)
{
$this->setUuid();
$this->parent = $parent;
$this->translations = new ArrayCollection();
foreach ($this->parent->getLanguages() as $lang) {
new JournalScientificCouncilMemberTranslation($this, $lang);
}
$this->createdAt = new \DateTimeImmutable();
$this->updatedAt = new \DateTimeImmutable();
$parent->addScientificCouncilMember($this);
}
public function getParent(): Journal
{
return $this->parent;
}
public function getName(): string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSurname(): string
{
return $this->surname;
}
public function setSurname(string $surname): self
{
$this->surname = $surname;
return $this;
}
#[Groups(['read'])]
public function getTitle(): ?string
{
return "{$this->name} {$this->surname}";
}
public function getOrcid(): ?string
{
return $this->orcid;
}
public function setOrcid(?string $orcid): self
{
$this->orcid = $orcid;
return $this;
}
public function getAffiliation(): ?Affiliation
{
return $this->affiliation;
}
public function setAffiliation(?Affiliation $affiliation): self
{
$this->affiliation = $affiliation;
return $this;
}
}