1212use Carbon \Carbon ;
1313use DateTimeInterface ;
1414use Doctrine \ORM \EntityManagerInterface ;
15+ use http \Exception \RuntimeException ;
1516use Illuminate \Support \Collection ;
1617use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
1718use Symfony \Component \Form \FormInterface ;
@@ -30,7 +31,7 @@ public function save(PostSubmitEvent $event, FormInterface $form, Collection $co
3031 {
3132 $ config = collect ($ config ->get ('contenttype ' , []));
3233
33- if (! $ config ) {
34+ if ($ config-> isEmpty () ) {
3435 return ;
3536 }
3637
@@ -48,7 +49,7 @@ public function save(PostSubmitEvent $event, FormInterface $form, Collection $co
4849 private function setContentData (Content $ content , Collection $ config ): void
4950 {
5051 $ content ->setStatus ($ config ->get ('status ' , Statuses::PUBLISHED ));
51- $ contentType = $ this ->boltConfig ->getContentType ($ config ->get ('name ' ));
52+ $ contentType = $ this ->boltConfig ->getContentType ($ config ->get ('name ' )) ?? throw new RuntimeException ( ' Content type not found ' ) ;
5253 $ content ->setContentType ($ contentType ->get ('slug ' ));
5354 $ content ->setDefinition ($ contentType );
5455
@@ -58,7 +59,7 @@ private function setContentData(Content $content, Collection $config): void
5859 }
5960 }
6061
61- private function setContentFields (Content $ content , Form $ form , PostSubmitEvent $ event , Collection $ config ): void
62+ private function setContentFields (Content $ content , FormInterface $ form , PostSubmitEvent $ event , Collection $ config ): void
6263 {
6364 $ mapping = collect ($ config ->get ('field_map ' ));
6465
0 commit comments