-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(podcast): add guests collection
- Loading branch information
1 parent
76a4476
commit e67472b
Showing
18 changed files
with
446 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Class Version20231028005726. | ||
* | ||
* @author bernard-ng <[email protected]> | ||
*/ | ||
final class Version20231028005726 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'add podcast episode guests table'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('CREATE TABLE content_podcast_episode_guests (episode_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', guest_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', INDEX IDX_363E5AB6362B62A0 (episode_id), INDEX IDX_363E5AB69A4AA658 (guest_id), PRIMARY KEY(episode_id, guest_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('ALTER TABLE content_podcast_episode_guests ADD CONSTRAINT FK_363E5AB6362B62A0 FOREIGN KEY (episode_id) REFERENCES content_podcast_episode (id) ON DELETE CASCADE'); | ||
$this->addSql('ALTER TABLE content_podcast_episode_guests ADD CONSTRAINT FK_363E5AB69A4AA658 FOREIGN KEY (guest_id) REFERENCES user (id) ON DELETE CASCADE'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE content_podcast_episode_guests DROP FOREIGN KEY FK_363E5AB6362B62A0'); | ||
$this->addSql('ALTER TABLE content_podcast_episode_guests DROP FOREIGN KEY FK_363E5AB69A4AA658'); | ||
$this->addSql('DROP TABLE content_podcast_episode_guests'); | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/Infrastructure/Authentication/Symfony/Form/Field/UserAutocompleteField.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Infrastructure\Authentication\Symfony\Form\Field; | ||
|
||
use Doctrine\ORM\EntityRepository; | ||
use Doctrine\ORM\QueryBuilder; | ||
use Domain\Authentication\Entity\User; | ||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
use Symfony\UX\Autocomplete\Form\AsEntityAutocompleteField; | ||
use Symfony\UX\Autocomplete\Form\ParentEntityAutocompleteType; | ||
|
||
/** | ||
* Class UserAutocompleteField. | ||
* | ||
* @author bernard-ng <[email protected]> | ||
*/ | ||
#[AsEntityAutocompleteField] | ||
class UserAutocompleteField extends AbstractType | ||
{ | ||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver->setDefaults([ | ||
'class' => User::class, | ||
'autocomplete' => true, | ||
'choice_label' => 'username', | ||
'placeholder' => 'pseudo de l\'utilisateur', | ||
'filter_query' => function (QueryBuilder $qb, string $query, EntityRepository $repository) { | ||
if (! $query) { | ||
return; | ||
} | ||
|
||
$qb->andWhere('entity.name LIKE :filter OR entity.username.username LIKE :filter') | ||
->setParameter('filter', '%' . $query . '%'); | ||
}, | ||
]); | ||
} | ||
|
||
public function getParent(): string | ||
{ | ||
return ParentEntityAutocompleteType::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/Infrastructure/Shared/Twig/Podcast/AppPodcastGuestCard.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Infrastructure\Shared\Twig\Podcast; | ||
|
||
use Domain\Authentication\Entity\User; | ||
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; | ||
|
||
/** | ||
* Class AppPodcastGuestCard. | ||
* | ||
* @author bernard-ng <[email protected]> | ||
*/ | ||
#[AsTwigComponent(template: '@app/shared/component/podcast/guest_card.html.twig')] | ||
final class AppPodcastGuestCard | ||
{ | ||
public User $guest; | ||
|
||
public function preMount(User $guest): void | ||
{ | ||
$this->guest = $guest; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.