protected function _createAndSave($type, $parent, $data, $callback = NULL) { $init = $this->_initFileData($type, $data, $parent->id(), $parent->_getFsId()); $entity = $this->_fileStorage->createObject($init); try { $this->_initFileAccess($entity); if ($callback) { call_user_func($callback, $entity); } $entity->save(); } catch (RM_Db_Exception_ConstraintViolation $e) { M('Trace')->trace('ofs', "Failed to create entity: " . $e->__toString()); // this should remove created file $entity->delete(); // here we can clean permission if needed throw new RM_ObjectFs_Exception_FileExists($parent, $entity); } return $entity; }
/** * Create mail variable object. * * @param name string variable name * @param mail_type_id string mail type identifier * * @return RM_Store_Object */ public function createVariable($name) { return $this->_variableStorage->createObject(array('name' => $name, 'mail_type_id' => '')); }
/** * Create template object connected with current mail type. * * @return RM_MailTemplate_Template */ public function createTemplate() { return $this->_templateStorage->createObject(array('mail_type_id' => $this->id(), 'active' => 'yes')); }
/** * Create mail object. * * @return RM_MailSend_Mail */ public function createMail() { return $this->_mailStorage->createObject(array('cdate' => M('Tools')->date()->dbDateTime(), 'body_type' => 'text/plain')); }
/** * Enter description here... * * @param array $data * @return RM_News_Object */ public function createNews($data) { return $this->_news->createObject($data); }
/** * Create attachment connected with current mail. * * @return RM_MailSend_Attachment */ public function createAttachment() { return $this->_attachStorage->createObject(array("mail_id" => $this->id())); }