44
55namespace PhpList \RestBundle \Identity \Controller ;
66
7+ use Doctrine \ORM \EntityManagerInterface ;
78use OpenApi \Attributes as OA ;
89use PhpList \Core \Domain \Identity \Model \Filter \AdminAttributeValueFilter ;
910use PhpList \Core \Domain \Identity \Model \Administrator ;
@@ -27,18 +28,21 @@ class AdminAttributeValueController extends BaseController
2728 private AdminAttributeManager $ attributeManager ;
2829 private AdminAttributeValueNormalizer $ normalizer ;
2930 private PaginatedDataProvider $ paginatedDataProvider ;
31+ private EntityManagerInterface $ entityManager ;
3032
3133 public function __construct (
3234 Authentication $ authentication ,
3335 RequestValidator $ validator ,
3436 AdminAttributeManager $ attributeManager ,
3537 AdminAttributeValueNormalizer $ normalizer ,
36- PaginatedDataProvider $ paginatedDataProvider
38+ PaginatedDataProvider $ paginatedDataProvider ,
39+ EntityManagerInterface $ entityManager ,
3740 ) {
3841 parent ::__construct ($ authentication , $ validator );
3942 $ this ->attributeManager = $ attributeManager ;
4043 $ this ->normalizer = $ normalizer ;
4144 $ this ->paginatedDataProvider = $ paginatedDataProvider ;
45+ $ this ->entityManager = $ entityManager ;
4246 }
4347
4448 #[Route(
@@ -122,6 +126,7 @@ public function createOrUpdate(
122126 definition: $ definition ,
123127 value: $ request ->toArray ()['value ' ] ?? null
124128 );
129+ $ this ->entityManager ->flush ();
125130 $ json = $ this ->normalizer ->normalize ($ attributeDefinition , 'json ' );
126131
127132 return $ this ->json ($ json , Response::HTTP_CREATED );
@@ -193,6 +198,7 @@ public function delete(
193198 throw $ this ->createNotFoundException ('Administrator attribute not found. ' );
194199 }
195200 $ this ->attributeManager ->delete ($ attribute );
201+ $ this ->entityManager ->flush ();
196202
197203 return $ this ->json (null , Response::HTTP_NO_CONTENT );
198204 }
@@ -350,6 +356,7 @@ public function getAttributeDefinition(
350356 attributeDefinitionId: $ definition ->getId ()
351357 );
352358 $ this ->attributeManager ->delete ($ attribute );
359+ $ this ->entityManager ->flush ();
353360
354361 return $ this ->json (
355362 $ this ->normalizer ->normalize ($ attribute ),
0 commit comments