/**
  * Returns a new PluginDataQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   PluginDataQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return PluginDataQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof PluginDataQuery) {
         return $criteria;
     }
     $query = new PluginDataQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
示例#2
0
 /**
  * Returns the number of related PluginData objects.
  *
  * @param Criteria $criteria
  * @param boolean $distinct
  * @param PropelPDO $con
  * @return int             Count of related PluginData objects.
  * @throws PropelException
  */
 public function countPluginDatas(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     $partial = $this->collPluginDatasPartial && !$this->isNew();
     if (null === $this->collPluginDatas || null !== $criteria || $partial) {
         if ($this->isNew() && null === $this->collPluginDatas) {
             return 0;
         }
         if ($partial && !$criteria) {
             return count($this->getPluginDatas());
         }
         $query = PluginDataQuery::create(null, $criteria);
         if ($distinct) {
             $query->distinct();
         }
         return $query->filterByPlugin($this)->count($con);
     }
     return count($this->collPluginDatas);
 }
示例#3
0
 /**
  * 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(PluginDataPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = PluginDataQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
示例#4
0
 */
$app->put('/organizations/:id/plugins/:op/:plugin_id', function ($org_id, $op, $plugin_id) use($app) {
    if_is_admin(function () use($app, $org_id, $op, $plugin_id) {
        $org = OrganizationQuery::create()->findPk($org_id);
        $plugin = PluginQuery::create()->findPk($plugin_id);
        if (!$org) {
            return error('unknown-organization', 'Organization not found');
        }
        if (!$plugin) {
            return error('unknown-plugin', 'Plugin not found');
        }
        if ($op == 'config') {
            $data = json_decode($app->request()->getBody(), true);
            // store custom config value
            $key = 'custom_config/' . $org->getId() . '/' . $data['key'];
            $q = PluginDataQuery::create()->filterByPlugin($plugin)->filterByKey($key)->findOne();
            if (is_null($data['value'])) {
                // remove value
                if ($q) {
                    $q->delete();
                }
                ok();
            } else {
                // udpate value
                if (!$q) {
                    $q = new PluginData();
                    $q->setPlugin($plugin);
                    $q->setKey($key);
                }
                $q->setData($data['value']);
                $q->setStoredAt(time());
 /**
  * Remove data from persistant plugin data store
  *
  * @param key   string   the key
  * @param data  json_seriazable   if set only matching items will be removed
  */
 public function deleteData($key, $data = null)
 {
     $q = PluginDataQuery::create()->filterByPlugin($this->getPluginOM())->filterByKey($key);
     if ($data !== null) {
         $q->filterByData(json_encode($data));
     }
     $q->delete();
 }