/** * Returns a new SystemEventQuery object. * * @param string $modelAlias The alias of a model in the query * @param SystemEventQuery|Criteria $criteria Optional Criteria to build the query from * * @return SystemEventQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof SystemEventQuery) { return $criteria; } $query = new SystemEventQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * API Action for api users to list events * * @param ApiRequest $request * * @return void */ public function executeSystemEvent(\sfAltumoPlugin\Api\ApiRequest $request) { try { /* @var $response \sfAltumoPlugin\Api\ApiResponse */ $response = $this->getResponse(); // authenticate and return user $user = $this->assertAndRetrieveAuthenticatedUser($request); //prepare the query $query = SystemEventQuery::create(); $query->addAscendingOrderByColumn(SystemEventPeer::UNIQUE_KEY); // if ids set, filter for those $ids_filter_value = $request->getParameter('ids'); if (!empty($ids_filter_value)) { $query->filterByPrimaryKey(\Altumo\Validation\Arrays::sanitizeCsvArrayPostitiveInteger($ids_filter_value)); } //make sure each of these fields have rhobust model validation that throws exceptions $field_mappings = array(); //do the before_save checks $before_save = function (&$model, &$request_object, &$response, $remote_id, $update) { }; switch ($request->getMethod()) { case sfWebRequest::GET: $response->setStatusCode('200'); $api_get_query = new \sfAltumoPlugin\Api\ApiGetQuery($request, $response, $query, 'system_events', $this->getSystemEventResultModifier()); $api_get_query->runQuery(); break; default: //action not supported $response->setStatusCode('405'); } } catch (Exception $e) { $response->addException($e); } return $response->respond(); }
/** * Get the associated SystemEvent object * * @param PropelPDO $con Optional Connection object. * @return SystemEvent The associated SystemEvent object. * @throws PropelException */ public function getSystemEvent(PropelPDO $con = null) { if ($this->aSystemEvent === null && $this->system_event_id !== null) { $this->aSystemEvent = SystemEventQuery::create()->findPk($this->system_event_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aSystemEvent->addSystemEventInstances($this); */ } return $this->aSystemEvent; }
/** * Gets a single SystemEvent by unique key. * * @return SystemEvent */ public static function retrieveByUniqueKey($unique_key) { return \SystemEventQuery::create()->filterByUniqueKey($unique_key)->findOne(); }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(SystemEventPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = SystemEventQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // symfony_behaviors behavior foreach (sfMixer::getCallables('BaseSystemEvent:delete:pre') as $callable) { if (call_user_func($callable, $this, $con)) { $con->commit(); return; } } if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); // symfony_behaviors behavior foreach (sfMixer::getCallables('BaseSystemEvent:delete:post') as $callable) { call_user_func($callable, $this, $con); } $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }