12 changed files with 186 additions and 10 deletions
@ -0,0 +1,80 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Entity; |
||||||
|
|
||||||
|
use App\Repository\JournalRepository; |
||||||
|
use Doctrine\ORM\Mapping as ORM; |
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: JournalRepository::class)] |
||||||
|
class Journal |
||||||
|
{ |
||||||
|
#[ORM\Id] |
||||||
|
#[ORM\GeneratedValue] |
||||||
|
#[ORM\Column] |
||||||
|
private ?int $id = null; |
||||||
|
|
||||||
|
#[ORM\Column(length: 255)] |
||||||
|
private ?string $npub = null; |
||||||
|
|
||||||
|
#[ORM\Column] |
||||||
|
private array $mainCategories = []; |
||||||
|
|
||||||
|
#[ORM\Column(nullable: true)] |
||||||
|
private ?array $lists = null; |
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)] |
||||||
|
private ?string $editor = null; |
||||||
|
|
||||||
|
public function getId(): ?int |
||||||
|
{ |
||||||
|
return $this->id; |
||||||
|
} |
||||||
|
|
||||||
|
public function getNpub(): ?string |
||||||
|
{ |
||||||
|
return $this->npub; |
||||||
|
} |
||||||
|
|
||||||
|
public function setNpub(string $npub): static |
||||||
|
{ |
||||||
|
$this->npub = $npub; |
||||||
|
|
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
public function getMainCategories(): array |
||||||
|
{ |
||||||
|
return $this->mainCategories; |
||||||
|
} |
||||||
|
|
||||||
|
public function setMainCategories(array $mainCategories): static |
||||||
|
{ |
||||||
|
$this->mainCategories = $mainCategories; |
||||||
|
|
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
public function getLists(): ?array |
||||||
|
{ |
||||||
|
return $this->lists; |
||||||
|
} |
||||||
|
|
||||||
|
public function setLists(?array $lists): static |
||||||
|
{ |
||||||
|
$this->lists = $lists; |
||||||
|
|
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
public function getEditor(): ?string |
||||||
|
{ |
||||||
|
return $this->editor; |
||||||
|
} |
||||||
|
|
||||||
|
public function setEditor(?string $editor): static |
||||||
|
{ |
||||||
|
$this->editor = $editor; |
||||||
|
|
||||||
|
return $this; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,43 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Repository; |
||||||
|
|
||||||
|
use App\Entity\Journal; |
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
||||||
|
use Doctrine\Persistence\ManagerRegistry; |
||||||
|
|
||||||
|
/** |
||||||
|
* @extends ServiceEntityRepository<Journal> |
||||||
|
*/ |
||||||
|
class JournalRepository extends ServiceEntityRepository |
||||||
|
{ |
||||||
|
public function __construct(ManagerRegistry $registry) |
||||||
|
{ |
||||||
|
parent::__construct($registry, Journal::class); |
||||||
|
} |
||||||
|
|
||||||
|
// /** |
||||||
|
// * @return Journal[] Returns an array of Journal objects |
||||||
|
// */ |
||||||
|
// public function findByExampleField($value): array |
||||||
|
// { |
||||||
|
// return $this->createQueryBuilder('j') |
||||||
|
// ->andWhere('j.exampleField = :val') |
||||||
|
// ->setParameter('val', $value) |
||||||
|
// ->orderBy('j.id', 'ASC') |
||||||
|
// ->setMaxResults(10) |
||||||
|
// ->getQuery() |
||||||
|
// ->getResult() |
||||||
|
// ; |
||||||
|
// } |
||||||
|
|
||||||
|
// public function findOneBySomeField($value): ?Journal |
||||||
|
// { |
||||||
|
// return $this->createQueryBuilder('j') |
||||||
|
// ->andWhere('j.exampleField = :val') |
||||||
|
// ->setParameter('val', $value) |
||||||
|
// ->getQuery() |
||||||
|
// ->getOneOrNullResult() |
||||||
|
// ; |
||||||
|
// } |
||||||
|
} |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Twig\Components\Molecules; |
||||||
|
|
||||||
|
use App\Entity\User; |
||||||
|
use Doctrine\ORM\EntityManagerInterface; |
||||||
|
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; |
||||||
|
|
||||||
|
#[AsTwigComponent] |
||||||
|
final class UserFromNpub |
||||||
|
{ |
||||||
|
public string $npub; |
||||||
|
public ?User $user = null; |
||||||
|
|
||||||
|
public function __construct(private EntityManagerInterface $entityManager) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public function mount(string $npub): void |
||||||
|
{ |
||||||
|
$this->npub = $npub; |
||||||
|
$this->user = $this->entityManager->getRepository(User::class)->findOneBy(['npub' => $npub]); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,5 @@ |
|||||||
|
{% if user %} |
||||||
|
<span>{{ user.displayName }}</span> |
||||||
|
{% else %} |
||||||
|
<span>{{ npub }}</span> |
||||||
|
{% endif %} |
||||||
@ -1,3 +1,5 @@ |
|||||||
<div {{ attributes }}> |
<div {{ attributes }}> |
||||||
<!-- component html --> |
{% for item in list %} |
||||||
|
<twig:Molecules:Card :article="item" ></twig:Molecules:Card> |
||||||
|
{% endfor %} |
||||||
</div> |
</div> |
||||||
|
|||||||
Loading…
Reference in new issue