1111use Symfony \Component \Console \Style \SymfonyStyle ;
1212use Symfony \Component \Filesystem \Filesystem ;
1313use Symfony \Component \Finder \Finder ;
14- use Psr \Log \LoggerInterface ;
1514
1615class InstallationService
1716{
@@ -336,15 +335,18 @@ public function handleInstaller($file)
336335 }
337336
338337 /**
339- * Handles forced id's on object entities
338+ * Handles forced id's on object entities.
340339 *
341340 * @param ObjectEntity $objectEntity
341+ *
342342 * @return ObjectEntity
343343 */
344- private function saveOnFixedId (ObjectEntity $ objectEntity ): ObjectEntity {
344+ private function saveOnFixedId (ObjectEntity $ objectEntity ): ObjectEntity
345+ {
345346 // This savetey dosn't make sense but we need it
346- if (!$ objectEntity ->getEntity ()){
347+ if (!$ objectEntity ->getEntity ()) {
347348 $ this ->io ->writeln (['' , 'Object can \'t be persisted due to missing schema ' ]);
349+
348350 return $ objectEntity ;
349351 }
350352
@@ -353,8 +355,7 @@ private function saveOnFixedId(ObjectEntity $objectEntity): ObjectEntity{
353355 $ objectEntity ->clearAllValues ();
354356
355357 // We have an object entity with a fixed id that isn't in the database, so we need to act
356- if ($ objectEntity ->getId () && !$ this ->em ->contains ($ objectEntity )){
357-
358+ if ($ objectEntity ->getId () && !$ this ->em ->contains ($ objectEntity )) {
358359 $ this ->io ->writeln (['' , 'Creating new object ( ' .$ objectEntity ->getEntity ()->getName ().') on a fixed id ( ' .$ objectEntity ->getId ().') ' ]);
359360
360361 // Sve the id
@@ -368,34 +369,29 @@ private function saveOnFixedId(ObjectEntity $objectEntity): ObjectEntity{
368369 $ this ->em ->persist ($ objectEntity );
369370 $ this ->em ->flush ();
370371 $ objectEntity = $ this ->em ->getRepository ('App:ObjectEntity ' )->findOneBy (['id ' => $ id ]);
371- }
372- else {
372+ } else {
373373 $ this ->io ->writeln (['' , 'Creating new object ( ' .$ objectEntity ->getEntity ()->getName ().') on a generated id ' ]);
374374 }
375375
376376 // Loop trough the values
377- foreach ($ values as $ objectValue ){
377+ foreach ($ values as $ objectValue ) {
378378 $ objectEntity ->addObjectValue ($ objectValue );
379379 // If the value itsself is an object it might also contain fixed id's
380- foreach ($ objectValue ->getObjects () as $ subobject ){
380+ foreach ($ objectValue ->getObjects () as $ subobject ) {
381381 $ this ->io ->writeln (['' , 'Found sub object ( ' .$ subobject ->getEntity ()->getName ().') ' ]);
382382 $ subobject = $ this ->saveOnFixedId ($ subobject );
383383
384384 // This savetey dosn't make sense but we need it
385- if (!$ subobject ->getEntity ()){
385+ if (!$ subobject ->getEntity ()) {
386386 // todo: Throw error
387387 $ objectEntity ->removeObjectValue ($ objectValue );
388388 }
389389 }
390-
391390 }
392391
393392 $ this ->em ->persist ($ objectEntity );
394393 $ this ->em ->flush ();
395394
396395 return $ objectEntity ;
397396 }
398-
399-
400-
401397}
0 commit comments