Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 17219 Rev 17222
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;
16
use LeadersLinked\Library\Storage;
17
use LeadersLinked\Library\Storage;
17
use LeadersLinked\Model\MicrolearningTopicCapsule;
18
use LeadersLinked\Model\MicrolearningTopicCapsule;
18
use LeadersLinked\Mapper\MicrolearningTopicCapsuleMapper;
19
use LeadersLinked\Mapper\MicrolearningTopicCapsuleMapper;
19
use LeadersLinked\Mapper\MicrolearningUserProgressMapper;
20
use LeadersLinked\Mapper\MicrolearningUserProgressMapper;
20
use LeadersLinked\Mapper\QueryMapper;
21
use LeadersLinked\Mapper\QueryMapper;
Línea 182... Línea 183...
182
                }
183
                }
Línea 183... Línea 184...
183
 
184
 
Línea 184... Línea 185...
184
                $dataPost = (array) $form->getData();
185
                $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'];
-
 
192
                $topic->type = $dataPost['type'];
186
 
193
                $topic->cost = $dataPost['cost'];
187
                $topic = new MicrolearningTopic();
194
                $topic->company_id = $currentCompany->id;
188
                $topic->company_id = $currentCompany->id;
Línea -... Línea 189...
-
 
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();
195
                $topic->image = '';
201
                $hydrator->hydrate($dataPost, $topic);
Línea 196... Línea 202...
196
                $topic->marketplace = '';
202
          
197
 
203
 
198
                $topicMapper = MicrolearningTopicMapper::getInstance($this->adapter);
204
                $topicMapper = MicrolearningTopicMapper::getInstance($this->adapter);
Línea 224... Línea 230...
224
                        return $this->createErrorResponse($topicMapper->getError());
230
                        return $this->createErrorResponse($topicMapper->getError());
225
                    }
231
                    }
226
                }
232
                }
Línea 227... Línea 233...
227
 
233
 
228
                // Create capsule relations
234
                // Create capsule relations
229
                $result = $this->updateTopicCapsuleRelations($topic, $dataPost['capsule_uuid'], $currentCompany->id);
235
                $result = $this->updateTopicCapsuleRelations($topic, $capsuleUuids, $currentCompany->id);
230
                if (!$result['success']) {
236
                if (!$result['success']) {
231
                    return $this->createErrorResponse($result['error']);
237
                    return $this->createErrorResponse($result['error']);
Línea 232... Línea 238...
232
                }
238
                }
Línea 449... Línea 455...
449
                    return $this->createErrorResponse('ERROR_UNAUTHORIZED');
455
                    return $this->createErrorResponse('ERROR_UNAUTHORIZED');
450
                }
456
                }
Línea 451... Línea 457...
451
 
457
 
Línea -... Línea 458...
-
 
458
                $dataPost = (array) $form->getData();
-
 
459
                
-
 
460
                // Extract capsule_uuid for separate handling and remove from hydration data
-
 
461
                $capsuleUuids = isset($dataPost['capsule_uuid']) ? $dataPost['capsule_uuid'] : [];
-
 
462
                if (!is_array($capsuleUuids)) {
-
 
463
                    $capsuleUuids = [$capsuleUuids];
-
 
464
                }
452
                $dataPost = (array) $form->getData();
465
                unset($dataPost['capsule_uuid']); // Remove to prevent dynamic property creation
453
                
466
                
Línea 454... Línea 467...
454
                $hydrator = new ObjectPropertyHydrator();
467
                $hydrator = new ObjectPropertyHydrator();
455
                $hydrator->hydrate($dataPost, $topic);
468
                $hydrator->hydrate($dataPost, $topic);
Línea 478... Línea 491...
478
                        return $this->createErrorResponse($topicMapper->getError());
491
                        return $this->createErrorResponse($topicMapper->getError());
479
                    }
492
                    }
480
                }
493
                }
Línea 481... Línea 494...
481
 
494
 
482
                // Update capsule relations
495
                // Update capsule relations
483
                $result = $this->updateTopicCapsuleRelations($topic, $dataPost['capsule_uuid'], $currentCompany->id);
496
                $result = $this->updateTopicCapsuleRelations($topic, $capsuleUuids, $currentCompany->id);
484
                if (!$result['success']) {
497
                if (!$result['success']) {
485
                    return $this->createErrorResponse($result['error']);
498
                    return $this->createErrorResponse($result['error']);
Línea 486... Línea 499...
486
                }
499
                }