/**
  * 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(SystemEventSubscriptionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = SystemEventSubscriptionQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         // symfony_behaviors behavior
         foreach (sfMixer::getCallables('BaseSystemEventSubscription: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('BaseSystemEventSubscription: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;
     }
 }
 /**
  * Returns a new SystemEventSubscriptionQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     SystemEventSubscriptionQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return SystemEventSubscriptionQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof SystemEventSubscriptionQuery) {
         return $criteria;
     }
     $query = new SystemEventSubscriptionQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Example #3
0
 /**
  * API Action for api users to crud event subscriptions
  * 
  * @param ApiRequest $request
  * 
  * @return void
  */
 public function executeSystemEventSubscription(\sfAltumoPlugin\Api\ApiRequest $request)
 {
     try {
         /* @var $response \sfAltumoPlugin\Api\ApiResponse() */
         $response = $this->getResponse();
         $user = $this->assertAndRetrieveAuthenticatedUser($request);
         //prepare the query
         $query = SystemEventSubscriptionQuery::create()->joinSystemEvent();
         // if ids set, filter for those
         $ids_filter_value = $request->getParameter('ids');
         if (!empty($ids_filter_value)) {
             $query->filterById(\Altumo\Validation\Arrays::sanitizeCsvArrayPostitiveInteger($ids_filter_value));
         }
         //do before_save checks
         $before_save = function (&$model, &$request_object, &$response, $remote_id, $update) {
             if (!$model->getUser()) {
                 $current_user = sfContext::getInstance()->getUser()->getUser();
                 $model->setUser($current_user);
             }
         };
         $plural = 'system_event_subscriptions';
         switch ($request->getMethod()) {
             case sfWebRequest::GET:
                 // select
                 $response->setStatusCode('200');
                 $api_get_query = new \sfAltumoPlugin\Api\ApiGetQuery($request, $response, $query, $plural, $this->getSystemEventSubscriptionResultModifier());
                 $api_get_query->runQuery();
                 break;
             case sfWebRequest::POST:
                 // insert
                 $response->setStatusCode('200');
                 $api_write_operation = new \sfAltumoPlugin\Api\ApiWriteOperation($request, $response, $plural);
                 $api_write_operation->setFieldMaps($this->getSystemEventSubscriptionFieldMappings());
                 $api_write_operation->setUpdate(false);
                 $api_write_operation->setQuery($query);
                 $api_write_operation->setModifyResult($this->getSystemEventSubscriptionResultModifier());
                 $api_write_operation->setBeforeSave($before_save);
                 $api_write_operation->run();
                 break;
             case sfWebRequest::PUT:
                 // update
                 $response->setStatusCode('200');
                 $api_write_operation = new \sfAltumoPlugin\Api\ApiWriteOperation($request, $response, $plural);
                 $api_write_operation->setFieldMaps($this->getSystemEventSubscriptionFieldMappings());
                 $api_write_operation->setUpdate(true);
                 $api_write_operation->setQuery($query);
                 $api_write_operation->setBeforeSave($before_save);
                 $api_write_operation->setModifyResult($this->getSystemEventSubscriptionResultModifier());
                 $api_write_operation->run();
                 break;
             case sfWebRequest::DELETE:
                 // delete
                 $response->setStatusCode('200');
                 $api_delete_operation = new \sfAltumoPlugin\Api\ApiDeleteOperation($request, $response, $query);
                 $api_delete_operation->run();
                 break;
             default:
                 // action not supported
                 $response->setStatusCode('405');
                 break;
         }
     } catch (Exception $e) {
         $response->addException($e);
     }
     return $response->respond();
 }
 /**
  * Get the associated SystemEventSubscription object
  *
  * @param      PropelPDO $con Optional Connection object.
  * @return                 SystemEventSubscription The associated SystemEventSubscription object.
  * @throws PropelException
  */
 public function getSystemEventSubscription(PropelPDO $con = null)
 {
     if ($this->aSystemEventSubscription === null && $this->system_event_subscription_id !== null) {
         $this->aSystemEventSubscription = SystemEventSubscriptionQuery::create()->findPk($this->system_event_subscription_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->aSystemEventSubscription->addSystemEventInstanceMessages($this);
            */
     }
     return $this->aSystemEventSubscription;
 }
Example #5
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this SystemEvent is new, it will return
  * an empty collection; or if this SystemEvent has previously
  * been saved, it will retrieve related SystemEventSubscriptions from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in SystemEvent.
  *
  * @param      Criteria $criteria optional Criteria object to narrow the query
  * @param      PropelPDO $con optional connection object
  * @param      string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  * @return PropelObjectCollection|SystemEventSubscription[] List of SystemEventSubscription objects
  */
 public function getSystemEventSubscriptionsJoinUser($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $query = SystemEventSubscriptionQuery::create(null, $criteria);
     $query->joinWith('User', $join_behavior);
     return $this->getSystemEventSubscriptions($query, $con);
 }