Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 17222 | Rev 17224 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 17222 Rev 17223
Línea 11... Línea 11...
11
use LeadersLinked\Mapper\MicrolearningTopicMapper;
11
use LeadersLinked\Mapper\MicrolearningTopicMapper;
12
use LeadersLinked\Mapper\MicrolearningCapsuleMapper;
12
use LeadersLinked\Mapper\MicrolearningCapsuleMapper;
13
use LeadersLinked\Model\MicrolearningTopic;
13
use LeadersLinked\Model\MicrolearningTopic;
14
use LeadersLinked\Form\Microlearning\TopicAddForm;
14
use LeadersLinked\Form\Microlearning\TopicAddForm;
15
use LeadersLinked\Form\Microlearning\TopicEditForm;
15
use LeadersLinked\Form\Microlearning\TopicEditForm;
16
use LeadersLinked\Hydrator\ObjectPropertyHydrator as HydratorObjectPropertyHydrator;
-
 
17
use LeadersLinked\Library\Storage;
16
use LeadersLinked\Library\Storage;
18
use LeadersLinked\Model\MicrolearningTopicCapsule;
17
use LeadersLinked\Model\MicrolearningTopicCapsule;
19
use LeadersLinked\Mapper\MicrolearningTopicCapsuleMapper;
18
use LeadersLinked\Mapper\MicrolearningTopicCapsuleMapper;
20
use LeadersLinked\Mapper\MicrolearningUserProgressMapper;
19
use LeadersLinked\Mapper\MicrolearningUserProgressMapper;
21
use LeadersLinked\Mapper\QueryMapper;
20
use LeadersLinked\Mapper\QueryMapper;
Línea 183... Línea 182...
183
                }
182
                }
Línea 184... Línea 183...
184
 
183
 
Línea 185... Línea 184...
185
                $dataPost = (array) $form->getData();
184
                $dataPost = (array) $form->getData();
-
 
185
 
-
 
186
                $topic = new MicrolearningTopic();
-
 
187
                $topic->name = $dataPost['name'];
-
 
188
                $topic->description = $dataPost['description'];
-
 
189
                $topic->order = $dataPost['order'];
-
 
190
                $topic->status = $dataPost['status'];        
-
 
191
                $topic->privacy = $dataPost['privacy'];
186
 
192
                $topic->type = $dataPost['type'];
187
                $topic = new MicrolearningTopic();
193
                $topic->cost = $dataPost['cost'];
188
                $topic->company_id = $currentCompany->id;
194
                $topic->company_id = $currentCompany->id;
Línea 189... Línea -...
189
                $topic->image = '';
-
 
190
                $topic->marketplace = '';
-
 
191
 
-
 
192
                unset($dataPost['capsule_uuid']);
-
 
193
 
-
 
194
                 // Create capsule relations
-
 
195
                 $capsuleUuids = isset($dataPost['capsule_uuid']) ? $dataPost['capsule_uuid'] : [];
-
 
196
                 if (!is_array($capsuleUuids)) {
-
 
197
                     $capsuleUuids = [$capsuleUuids];
-
 
198
                 }
-
 
199
 
-
 
200
                $hydrator = new HydratorObjectPropertyHydrator();
-
 
201
                $hydrator->hydrate($dataPost, $topic);
195
                $topic->image = '';
Línea 202... Línea 196...
202
          
196
                $topic->marketplace = '';
203
 
197
 
204
                $topicMapper = MicrolearningTopicMapper::getInstance($this->adapter);
198
                $topicMapper = MicrolearningTopicMapper::getInstance($this->adapter);
Línea 230... Línea 224...
230
                        return $this->createErrorResponse($topicMapper->getError());
224
                        return $this->createErrorResponse($topicMapper->getError());
231
                    }
225
                    }
232
                }
226
                }
Línea 233... Línea 227...
233
 
227
 
234
                // Create capsule relations
228
                // Create capsule relations
235
                $result = $this->updateTopicCapsuleRelations($topic, $capsuleUuids, $currentCompany->id);
229
                $result = $this->updateTopicCapsuleRelations($topic, $dataPost['capsule_uuid'], $currentCompany->id);
236
                if (!$result['success']) {
230
                if (!$result['success']) {
237
                    return $this->createErrorResponse($result['error']);
231
                    return $this->createErrorResponse($result['error']);
Línea 238... Línea 232...
238
                }
232
                }
Línea 455... Línea 449...
455
                    return $this->createErrorResponse('ERROR_UNAUTHORIZED');
449
                    return $this->createErrorResponse('ERROR_UNAUTHORIZED');
456
                }
450
                }
Línea 457... Línea 451...
457
 
451
 
Línea 458... Línea 452...
458
                $dataPost = (array) $form->getData();
452
                $dataPost = (array) $form->getData();
459
                
453
                
460
                // Extract capsule_uuid for separate handling and remove from hydration data
454
                $topic->name = $dataPost['name'];
461
                $capsuleUuids = isset($dataPost['capsule_uuid']) ? $dataPost['capsule_uuid'] : [];
455
                $topic->description = $dataPost['description'];
462
                if (!is_array($capsuleUuids)) {
-
 
463
                    $capsuleUuids = [$capsuleUuids];
456
                $topic->order = $dataPost['order'];
464
                }
-
 
465
                unset($dataPost['capsule_uuid']); // Remove to prevent dynamic property creation
457
                $topic->status = $dataPost['status'];        
466
                
458
                $topic->privacy = $dataPost['privacy'];
Línea 467... Línea 459...
467
                $hydrator = new ObjectPropertyHydrator();
459
                $topic->type = $dataPost['type'];
468
                $hydrator->hydrate($dataPost, $topic);
460
                $topic->cost = $dataPost['cost'];
469
 
461
 
470
                // Update basic topic data first
462
                // Update basic topic data first
Línea 491... Línea 483...
491
                        return $this->createErrorResponse($topicMapper->getError());
483
                        return $this->createErrorResponse($topicMapper->getError());
492
                    }
484
                    }
493
                }
485
                }
Línea 494... Línea 486...
494
 
486
 
495
                // Update capsule relations
487
                // Update capsule relations
496
                $result = $this->updateTopicCapsuleRelations($topic, $capsuleUuids, $currentCompany->id);
488
                $result = $this->updateTopicCapsuleRelations($topic, $dataPost['capsule_uuid'], $currentCompany->id);
497
                if (!$result['success']) {
489
                if (!$result['success']) {
498
                    return $this->createErrorResponse($result['error']);
490
                    return $this->createErrorResponse($result['error']);
Línea 499... Línea 491...
499
                }
491
                }