/** * Declares an association between this object and a Room object. * * @param Room $v * @return RoomHasFeaturevalue The current object (for fluent API support) * @throws PropelException */ public function setRoom(Room $v = null) { if ($v === null) { $this->setRoomId(NULL); } else { $this->setRoomId($v->getId()); } $this->aRoom = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Room object, it will not be re-added. if ($v !== null) { $v->addRoomHasFeaturevalue($this); } return $this; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Room $value A Room object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Room $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * Save room. */ function execute() { $roomDao = DAORegistry::getDAO('RoomDAO'); $schedConf =& Request::getSchedConf(); if (isset($this->roomId)) { $room =& $roomDao->getRoom($this->roomId); } if (!isset($room)) { $room = new Room(); } $room->setBuildingId($this->buildingId); $room->setName($this->getData('name'), null); // Localized $room->setAbbrev($this->getData('abbrev'), null); // Localized $room->setDescription($this->getData('description'), null); // Localized // Update or insert room if ($room->getId() != null) { $roomDao->updateRoom($room); } else { $roomDao->insertRoom($room); } }
/** * * @param sfWebRequest $request * @param sfForm $form * @param Room $room * @return <bool> false if preview action */ protected function processTopicForm(sfWebRequest $request, sfForm $form, Room $room, User $user) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { if ($this->getRequestParameter('submitAct')) { $values = $form->getValues(); // topic saving $topic = new Topic(); $topic->setTitle($values['title']); $topic->setIdRoom($room->getId()); $topic->setIdUser($user->getId()); $topic->save(); // post saving $post = new Post(); $post->setContent($values['post']['content']); $post->setIdTopic($topic->getId()); $post->setIdUser($user->getId()); $post->save(); $this->redirect('room_topic_show', $topic); } else { if ($this->getRequestParameter('prevSubmitAct')) { return; } else { return false; } } } }
protected function processCopyForm(sfWebRequest $request, sfForm $form, Room $room) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); if ($form->isValid()) { $this->forward404Unless($copyRoom = RoomPeer::retrieveByPk($form->getValue('copyRoom_id')), sprintf('Object room does not exist (%s).', $form->getValue('copyRoom_id'))); if ($copyRoom->getId() != $room->getId()) { $room->copyDayperiodsFromRoom($copyRoom); $room->save(); } $this->redirect('dayperiod/index?roomId=' . $room->getId()); } }
public function copyDayperiodsFromRoom(Room $room) { if ($room->getId() == $this->getId()) { return; } $this->clearDayperiods(); $dayperiods = $room->getDayperiods(); foreach ($dayperiods as $dayperiod) { $newDayperiod = $dayperiod->copyWithoutRoom(); $this->addDayperiod($newDayperiod); } }