示例#1
0
 /**
  * Implementation for 'GET' method for Rest API
  *
  * @param  mixed $stgUid Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function get($stgUid = null)
 {
     $result = array();
     try {
         $noArguments = true;
         $argumentList = func_get_args();
         foreach ($argumentList as $arg) {
             if (!is_null($arg)) {
                 $noArguments = false;
             }
         }
         if ($noArguments) {
             $criteria = new Criteria('workflow');
             $criteria->addSelectColumn(StagePeer::STG_UID);
             $criteria->addSelectColumn(StagePeer::PRO_UID);
             $criteria->addSelectColumn(StagePeer::STG_POSX);
             $criteria->addSelectColumn(StagePeer::STG_POSY);
             $criteria->addSelectColumn(StagePeer::STG_INDEX);
             $dataset = AppEventPeer::doSelectRS($criteria);
             $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             while ($dataset->next()) {
                 $result[] = $dataset->getRow();
             }
         } else {
             $record = StagePeer::retrieveByPK($stgUid);
             if ($record) {
                 $result = $record->toArray(BasePeer::TYPE_FIELDNAME);
             } else {
                 $paramValues = "";
                 foreach ($argumentList as $arg) {
                     $paramValues .= strlen($paramValues) ? ', ' : '';
                     if (!is_null($arg)) {
                         $paramValues .= "{$arg}";
                     } else {
                         $paramValues .= "NULL";
                     }
                 }
                 throw new RestException(417, "table Stage ({$paramValues})");
             }
         }
     } catch (RestException $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
     return $result;
 }
示例#2
0
 public function remove($StgUid)
 {
     $con = Propel::getConnection(StagePeer::DATABASE_NAME);
     try {
         $con->begin();
         $oStage = StagePeer::retrieveByPK($StgUid);
         if (!is_null($oStage)) {
             Content::removeContent('STG_TITLE', '', $this->getStgUid());
             $result = $oStage->delete();
             $con->commit();
         }
         return $result;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }