-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0defe8
commit 90f88b1
Showing
24 changed files
with
702 additions
and
114 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,2 @@ | ||
1. Attention à la création des communautés / places ! | ||
Les fields et leurs entités doivent être persistés ensemble avant de flush |
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
57 changes: 57 additions & 0 deletions
57
src/Community/Infrastructure/Doctrine/DoctrineCommunityListener.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,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Community\Infrastructure\Doctrine; | ||
|
||
use App\Community\Domain\Enum\CommunityType; | ||
use App\Community\Domain\Model\Community; | ||
use App\Core\Domain\Search\Helper\SearchHelperInterface; | ||
use App\Field\Domain\Enum\FieldCommunity; | ||
use App\Shared\Domain\Enum\SearchIndex; | ||
use Doctrine\Bundle\DoctrineBundle\Attribute\AsEntityListener; | ||
use Doctrine\ORM\Events; | ||
|
||
#[AsEntityListener(event: Events::postPersist, method: 'postPersist', entity: Community::class)] | ||
final class DoctrineCommunityListener | ||
{ | ||
public function __construct( | ||
private readonly SearchHelperInterface $searchHelper, | ||
) { | ||
} | ||
|
||
public function postPersist(Community $community): void | ||
{ | ||
$type = $community->getMostTrustableFieldByName(FieldCommunity::TYPE)?->getValue(); | ||
if ($type === CommunityType::PARISH->value) { | ||
// A new parish has been inserted | ||
$parishName = $community->getMostTrustableFieldByName(FieldCommunity::NAME)?->getValue(); | ||
$dioceseName = null; | ||
/** @var Community|null $diocese */ | ||
$diocese = $community->getMostTrustableFieldByName(FieldCommunity::PARENT_COMMUNITY_ID)?->getValue(); | ||
if ($diocese) { | ||
$dioceseName = $diocese->getMostTrustableFieldByName(FieldCommunity::NAME)?->getValue(); | ||
} | ||
$this->searchHelper->upsertElement( | ||
SearchIndex::PARISH, | ||
$community->id->toString(), | ||
[ | ||
'parishName' => $parishName, | ||
'dioceseName' => $dioceseName, | ||
] | ||
); | ||
} | ||
|
||
if ($type === CommunityType::DIOCESE->value) { | ||
// A new diocese has been inserted | ||
$dioceseName = $community->getMostTrustableFieldByName(FieldCommunity::NAME)?->getValue(); | ||
$this->searchHelper->upsertElement( | ||
SearchIndex::DIOCESE, | ||
$community->id->toString(), | ||
[ | ||
'dioceseName' => $dioceseName, | ||
] | ||
); | ||
} | ||
} | ||
} |
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
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.