@@ -50,6 +50,7 @@ public function __construct
5050
5151 /**
5252 * @inheritDoc
53+ * @throws \Exception
5354 */
5455 public function add (array $ payload ): SummitMediaFileType
5556 {
@@ -71,10 +72,11 @@ public function add(array $payload): SummitMediaFileType
7172
7273 /**
7374 * @inheritDoc
75+ * @throws \Exception
7476 */
7577 public function update (int $ id , array $ payload ): SummitMediaFileType
7678 {
77- return $ this ->tx_service ->transaction (function () use ($ id , $ payload ){
79+ $ media_file_type = $ this ->tx_service ->transaction (function () use ($ id , $ payload ){
7880 $ type = $ this ->repository ->getById ($ id );
7981 if (is_null ($ type ))
8082 throw new EntityNotFoundException ();
@@ -86,23 +88,23 @@ public function update(int $id, array $payload): SummitMediaFileType
8688 if (!is_null ($ type ) && $ type ->getId () != $ id )
8789 throw new ValidationException (sprintf ("Name %s already exists. " , $ payload ['name ' ]));
8890 }
91+ return SummitMediaFileTypeFactory::populate ($ type , $ payload );
92+ });
8993
90- $ media_file_type = SummitMediaFileTypeFactory::populate ($ type , $ payload );
91-
92- PublishSponsorServiceDomainEventsJob::dispatch (
93- SummitMediaFileTypeCreatedEventDTO::fromSummitMediaFileType ($ media_file_type )->serialize (),
94- SummitMediaFileTypeDomainEvents::SummitMediaFileTypeUpdated);
94+ PublishSponsorServiceDomainEventsJob::dispatch (
95+ SummitMediaFileTypeCreatedEventDTO::fromSummitMediaFileType ($ media_file_type )->serialize (),
96+ SummitMediaFileTypeDomainEvents::SummitMediaFileTypeUpdated);
9597
96- return $ media_file_type ;
97- });
98+ return $ media_file_type ;
9899 }
99100
100101 /**
101102 * @inheritDoc
103+ * @throws \Exception
102104 */
103105 public function delete (int $ id ): void
104106 {
105- $ this ->tx_service ->transaction (function () use ($ id ){
107+ $ type = $ this ->tx_service ->transaction (function () use ($ id ){
106108 $ type = $ this ->repository ->getById ($ id );
107109 if (is_null ($ type ))
108110 throw new EntityNotFoundException ();
@@ -111,9 +113,11 @@ public function delete(int $id): void
111113
112114 $ this ->repository ->delete ($ type );
113115
114- PublishSponsorServiceDomainEventsJob::dispatch (
115- DeletedEventDTO::fromEntity ($ type )->serialize (),
116- SummitMediaFileTypeDomainEvents::SummitMediaFileTypeDeleted);
116+ return $ type ;
117117 });
118+
119+ PublishSponsorServiceDomainEventsJob::dispatch (
120+ DeletedEventDTO::fromEntity ($ type )->serialize (),
121+ SummitMediaFileTypeDomainEvents::SummitMediaFileTypeDeleted);
118122 }
119123}
0 commit comments