Skip to content

Commit

Permalink
Renamed templates for BaseCrudDtoController
Browse files Browse the repository at this point in the history
  • Loading branch information
dragosprotung committed Mar 19, 2024
1 parent 4ebd93b commit 6164328
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/Controller/BaseCrudDtoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,42 @@
/**
* Original inspiration from https://gist.github.com/ragboyjr/2ed5734eb839483ca22892f6955b2792
*
* @template TEntityClass of object
* @template TDtoClass of object
* @template TEntity of object
* @template TDto of object
* @template-extends BaseCrudController<TEntity>
*/
abstract class BaseCrudDtoController extends BaseCrudController implements EventSubscriberInterface
{
/** @var TEntityClass|null */
/** @var TEntity|null */
private object|null $temporaryEntityForEdit = null;

/**
* @return class-string<TEntityClass>
* @return class-string<TEntity>
*/
abstract public static function getEntityFqcn(): string;

/**
* @return class-string<TDtoClass>
* @return class-string<TDto>
*/
abstract public static function getDtoFqcn(): string;

/**
* @param TDtoClass $dto
* @param TDto $dto
*
* @return TEntityClass|null
* @return TEntity|null
*/
abstract public function createEntityFromDto(object $dto): object|null;

/**
* @param TEntityClass $entity
* @param TEntity $entity
*
* @return TDtoClass
* @return TDto
*/
abstract public function createDtoFromEntity(object $entity): object;

/**
* @param TEntityClass $entity
* @param TDtoClass $dto
* @param TEntity $entity
* @param TDto $dto
*/
abstract public function updateEntityFromDto(object $entity, object $dto): void;

Expand All @@ -82,7 +83,7 @@ final public function convertDtoToEntityFromBeforeEntityPersistedEvent(BeforeEnt
$entity = $this->createEntityFromDto($dto);

/**
* @param TEntityClass|null $entity
* @param TEntity|null $entity
*/
$closure = function (object|null $entity): void {
$this->entityInstance = $entity;
Expand Down Expand Up @@ -119,7 +120,7 @@ final public function convertEntityToDtoFromBeforeCrudActionEvent(BeforeCrudActi
$dto = $this->createDtoFromEntity($this->temporaryEntityForEdit);

/**
* @param TDtoClass $dto
* @param TDto $dto
*/
$closure = function (object $dto): void {
$this->instance = $dto;
Expand All @@ -145,7 +146,7 @@ final public function convertDtoToUpdatedEntityFromBeforeEntityUpdatedEvent(Befo
$this->updateEntityFromDto($this->temporaryEntityForEdit, $dto);

/**
* @param TEntityClass $entity
* @param TEntity $entity
*/
$closure = function (object $entity): void {
$this->entityInstance = $entity;
Expand Down Expand Up @@ -186,7 +187,7 @@ private function removeEntityInstanceFromAdminContext(AdminContext $adminContext
}

/**
* @return TDtoClass
* @return TDto
*/
public function createEntity(string $entityFqcn): object
{
Expand Down

0 comments on commit 6164328

Please sign in to comment.