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()); } }