Exemplo n.º 1
0
 /**
  * Delete the task passing request object
  *
  * @param Request $request Request that is used for this delete method, $request->getDataObject(0) will contain
  *                         query data to fetch the old object
  *
  * @return void
  */
 public function delete(Request $request)
 {
     /** @var \Tasker\Mapper\Task\Entity $mapper */
     $mapper = DbMapperFactory::make('task|entity');
     $mapper->setArrays($request->getData());
     $dbAttributesForQuery = $mapper->getMappedSecondAttributes();
     $taskQuery = new TaskQuery();
     // Get the old entity
     /** @var \Propel\Runtime\Collection\ObjectCollection $dbEntities */
     $dbEntities = $taskQuery->findByArray($dbAttributesForQuery);
     /** @var \Tasker\DataGateway\Db\Entity\Task $dbEntity */
     $dbEntities->delete();
     // Return empty array that it will indicate a deleted collection to the caller
     $this->setEntitiesFromResponse([]);
 }
Exemplo n.º 2
0
 /**
  * Returns a new ChildTaskQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return ChildTaskQuery
  */
 public static function create($modelAlias = null, Criteria $criteria = null)
 {
     if ($criteria instanceof ChildTaskQuery) {
         return $criteria;
     }
     $query = new ChildTaskQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Exemplo n.º 3
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      ConnectionInterface $con
  * @return void
  * @throws PropelException
  * @see Task::setDeleted()
  * @see Task::isDeleted()
  */
 public function delete(ConnectionInterface $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getServiceContainer()->getWriteConnection(TaskTableMap::DATABASE_NAME);
     }
     $con->transaction(function () use($con) {
         $deleteQuery = ChildTaskQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $this->setDeleted(true);
         }
     });
 }