-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Ivoz\Core\Domain\Service\Repository; | ||
|
||
use Doctrine\Common\Collections\Selectable; | ||
use Doctrine\Persistence\ObjectRepository; | ||
use Ivoz\Core\Domain\DataTransferObjectInterface; | ||
use Ivoz\Core\Domain\Model\EntityInterface; | ||
|
||
/** | ||
* @template EntityT of EntityInterface | ||
* @template DtoT of DataTransferObjectInterface | ||
* @template-extends ObjectRepository<EntityT> | ||
* @template-extends Selectable<EntityT> | ||
*/ | ||
interface RepositoryInterface extends ObjectRepository, Selectable | ||
Check failure on line 16 in Domain/Service/Repository/RepositoryInterface.php GitHub Actions / build
Check failure on line 16 in Domain/Service/Repository/RepositoryInterface.php GitHub Actions / build
|
||
{ | ||
/** | ||
* @param DtoT $dto | ||
* @param EntityT|null $entity | ||
* @return EntityT | ||
*/ | ||
public function persistDto(DataTransferObjectInterface $dto, EntityInterface $entity = null, $dispatchImmediately = false): EntityInterface; | ||
|
||
/** | ||
* @param EntityT $entity | ||
*/ | ||
public function persist(EntityInterface $entity, bool $dispatchImmediately = false): void; | ||
|
||
/** | ||
* @param EntityT $entity | ||
*/ | ||
public function remove(EntityInterface $entity): void; | ||
|
||
/** | ||
* @param EntityT[] $entities | ||
*/ | ||
public function removeFromArray(array $entities): void; | ||
|
||
public function dispatchQueued(): void; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
namespace Ivoz\Core\Infrastructure\Persistence\Doctrine\Repository; | ||
|
||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||
use Doctrine\Persistence\ManagerRegistry; | ||
use Ivoz\Core\Domain\DataTransferObjectInterface; | ||
use Ivoz\Core\Domain\Model\EntityInterface; | ||
use Ivoz\Core\Domain\Service\EntityPersisterInterface; | ||
use Ivoz\Core\Domain\Service\Repository\RepositoryInterface; | ||
|
||
/** | ||
* CompanyDoctrineRepository | ||
* | ||
* This class was generated by the Doctrine ORM. Add your own custom | ||
* repository methods below. | ||
* | ||
* @template EntityT of EntityInterface | ||
* @template DtoT of DataTransferObjectInterface | ||
* @template-extends ServiceEntityRepository<EntityT> | ||
*/ | ||
class DoctrineRepository extends ServiceEntityRepository implements RepositoryInterface | ||
Check failure on line 22 in Infrastructure/Persistence/Doctrine/Repository/DoctrineRepository.php GitHub Actions / build
Check failure on line 22 in Infrastructure/Persistence/Doctrine/Repository/DoctrineRepository.php GitHub Actions / build
Check failure on line 22 in Infrastructure/Persistence/Doctrine/Repository/DoctrineRepository.php GitHub Actions / build
Check failure on line 22 in Infrastructure/Persistence/Doctrine/Repository/DoctrineRepository.php GitHub Actions / build
Check failure on line 22 in Infrastructure/Persistence/Doctrine/Repository/DoctrineRepository.php GitHub Actions / build
Check failure on line 22 in Infrastructure/Persistence/Doctrine/Repository/DoctrineRepository.php GitHub Actions / build
Check failure on line 22 in Infrastructure/Persistence/Doctrine/Repository/DoctrineRepository.php GitHub Actions / build
Check failure on line 22 in Infrastructure/Persistence/Doctrine/Repository/DoctrineRepository.php GitHub Actions / build
|
||
{ | ||
public function __construct( | ||
ManagerRegistry $registry, | ||
string $entityClass, | ||
private EntityPersisterInterface $entityPersister, | ||
) { | ||
parent::__construct( | ||
$registry, | ||
$entityClass | ||
); | ||
} | ||
|
||
/** | ||
* @param DtoT $dto | ||
* @param EntityT|null $entity | ||
* @return EntityT | ||
*/ | ||
public function persistDto(DataTransferObjectInterface $dto, EntityInterface $entity = null, $dispatchImmediately = false): EntityInterface | ||
{ | ||
return | ||
$this | ||
->entityPersister | ||
->persistDto( | ||
$dto, | ||
$entity, | ||
$dispatchImmediately | ||
); | ||
} | ||
|
||
/** | ||
* @param EntityT $entity | ||
*/ | ||
public function persist(EntityInterface $entity, bool $dispatchImmediately = false): void | ||
{ | ||
$this | ||
->entityPersister | ||
->persist( | ||
$entity, | ||
$dispatchImmediately | ||
); | ||
} | ||
|
||
/** | ||
* @param EntityT $entity | ||
*/ | ||
public function remove(EntityInterface $entity): void | ||
{ | ||
$this | ||
->entityPersister | ||
->remove( | ||
$entity | ||
); | ||
} | ||
|
||
/** | ||
* @param EntityT[] $entities | ||
*/ | ||
public function removeFromArray(array $entities): void | ||
{ | ||
$this | ||
->entityPersister | ||
->removeFromArray( | ||
$entities | ||
); | ||
} | ||
|
||
public function dispatchQueued(): void | ||
{ | ||
$this->entityPersister->dispatchQueued(); | ||
} | ||
} |