@@ -2129,7 +2129,6 @@ public function deleteBookableRoomAttributeValue(Summit $summit, int $type_id, i
21292129 });
21302130 }
21312131
2132-
21332132 /**
21342133 * @param int $summit_id
21352134 * @param UploadedFile $file
@@ -2146,8 +2145,8 @@ public function addSummitLogo(int $summit_id, UploadedFile $file, $max_file_size
21462145
21472146 $ summit = $ this ->summit_repository ->getById ($ summit_id );
21482147
2149- if (is_null ( $ summit ) || !$ summit instanceof Summit) {
2150- throw new EntityNotFoundException ('summit not found! ' );
2148+ if (!$ summit instanceof Summit) {
2149+ throw new EntityNotFoundException ('Summit not found. ' );
21512150 }
21522151
21532152 if (!in_array ($ file ->extension (), $ allowed_extensions )) {
@@ -2176,14 +2175,68 @@ public function deleteSummitLogo(int $summit_id): void
21762175
21772176 $ summit = $ this ->summit_repository ->getById ($ summit_id );
21782177
2179- if (is_null ( $ summit ) || !$ summit instanceof Summit) {
2180- throw new EntityNotFoundException ('summit not found! ' );
2178+ if (!$ summit instanceof Summit) {
2179+ throw new EntityNotFoundException ('Summit not found. ' );
21812180 }
21822181
21832182 $ summit ->clearLogo ();
21842183 });
21852184 }
21862185
2186+ /**
2187+ * @param int $summit_id
2188+ * @param UploadedFile $file
2189+ * @param int $max_file_size
2190+ * @return File
2191+ * @throws EntityNotFoundException
2192+ * @throws ValidationException
2193+ */
2194+ public function addSummitSecondaryLogo (int $ summit_id , UploadedFile $ file , $ max_file_size = 10485760 )
2195+ {
2196+ return $ this ->tx_service ->transaction (function () use ($ summit_id , $ file , $ max_file_size ) {
2197+
2198+ $ allowed_extensions = ['png ' , 'jpg ' , 'jpeg ' , 'gif ' , 'svg ' , 'jfif ' ];
2199+
2200+ $ summit = $ this ->summit_repository ->getById ($ summit_id );
2201+
2202+ if (!$ summit instanceof Summit) {
2203+ throw new EntityNotFoundException ('Summit not found. ' );
2204+ }
2205+
2206+ if (!in_array ($ file ->extension (), $ allowed_extensions )) {
2207+ throw new ValidationException (sprintf ("file does not has a valid extension (%s). " , implode (", " , $ allowed_extensions )));
2208+ }
2209+
2210+ if ($ file ->getSize () > $ max_file_size ) {
2211+ throw new ValidationException (sprintf ("file exceeds max_file_size (%s MB). " , ($ max_file_size / 1024 ) / 1024 ));
2212+ }
2213+
2214+ $ photo = $ this ->file_uploader ->build ($ file , sprintf ('summits/%s ' , $ summit ->getId ()), true );
2215+ $ summit ->setSecondaryLogo ($ photo );
2216+
2217+ return $ photo ;
2218+ });
2219+ }
2220+
2221+ /**
2222+ * @param int $summit_id
2223+ * @throws ValidationException
2224+ * @throws EntityNotFoundException
2225+ */
2226+ public function deleteSummitSecondaryLogo (int $ summit_id ): void
2227+ {
2228+ $ this ->tx_service ->transaction (function () use ($ summit_id ) {
2229+
2230+ $ summit = $ this ->summit_repository ->getById ($ summit_id );
2231+
2232+ if (!$ summit instanceof Summit) {
2233+ throw new EntityNotFoundException ('Summit not found. ' );
2234+ }
2235+
2236+ $ summit ->clearSecondaryLogo ();
2237+ });
2238+ }
2239+
21872240 /**
21882241 * @param Summit $summit
21892242 * @param Member $member
0 commit comments