public function save($con = null, $parent = null, $refreshTree = true) { try { $con = Propel::getConnection(); $con->begin(); $genericDoc = Document::getGenericDocument($this); if (!$this->getId()) { $this->setId($genericDoc->getId()); } parent::save($con); // create relationship if (!$parent) { $parent = Document::getParentOf($this->getId(), null, true, false); if (empty($parent)) { $parent = Rootfolder::getRootfolder($this); } } Relation::saveRelation($parent, $this); $con->commit(); Document::cacheObj($this, "Media", $refreshTree); return true; } catch (Exception $e) { $con->rollback(); throw $e; } }
/** * Returns a peer instance associated with this om. * * Since Peer classes are not to have any instance attributes, this method returns the * same instance for all member of this class. The method could therefore * be static, but this would prevent one from overriding the behavior. * * @return MediaPeer */ public function getPeer() { if (self::$peer === null) { self::$peer = new MediaPeer(); } return self::$peer; }
/** * JsonText constructor. * * 或者不重写方法, 直接在Render方法中进行处理, 两者皆可.符合设计原则. * 如果在Render中设置,需要判断格式,异常处理等. * * @param array $content */ public function __construct(array $content) { parent::__construct(json_encode($content)); }