public function createFromFrame($idFrame)
 {
     $transaction = $this->beginTransaction();
     try {
         $frame = new Frame($idFrame);
         $this->setEntry('tpl_' . strtolower(str_replace('frm_', '', $frame->getEntry())));
         $this->save();
         Base::createEntityRelation($this->getIdEntity(), 'rel_createdfrom', $frame->getIdEntity());
         $fes = $frame->listFE()->asQuery()->asObjectArray();
         $fe = new FrameElement();
         foreach ($fes as $feData) {
             $fe->setPersistent(false);
             $feEntry = $this->getEntry() . '_' . $feData->entry;
             $entry = new Entry();
             $entry->cloneEntry($feData->entry, $feEntry);
             $fe->setEntry($feData->entry);
             $entity = new Entity();
             $entity->setAlias($feEntry);
             $entity->setType('FE');
             $entity->save();
             Base::createEntityRelation($entity->getId(), 'rel_elementof', $this->getIdEntity());
             $coreType = new TypeInstance($feData->idCoreType);
             Base::createEntityRelation($entity->getId(), 'rel_hastype', $coreType->getIdEntity());
             $fe->setIdEntity($entity->getId());
             $fe->setActive(true);
             $fe->setIdColor($feData->idColor);
             $fe->saveModel();
         }
         $transaction->commit();
     } catch (\Exception $e) {
         $transaction->rollback();
         throw new \Exception($e->getMessage());
     }
 }
Exemplo n.º 2
0
 public function formNewLU()
 {
     $this->data->idFrame = $this->data->id;
     $model = new Frame($this->data->idFrame);
     $this->data->frame = 'Frame:  ' . $model->getEntry() . '  [' . $model->getName() . ']';
     $model = new Lemma();
     $this->data->query = Manager::getAppURL('fnbr20', 'structure/frame/gridSearchLemmaData');
     $this->data->save = "@fnbr20/structure/frame/newLU|formNewLU";
     $this->data->close = "!\$('#formNewLU_dialog').dialog('close');structure.reloadFrame()";
     $this->data->title = _M('New LU');
     $this->render();
 }