예제 #1
0
 /**
  * @param null $criteria
  * @return mixed
  */
 public function remove($criteria = null)
 {
     if (!isset($criteria)) {
         $criteria = array("id" => $this->getPrimaryKey());
     }
     return $this->entityManager->remove($this->tableName, $criteria);
 }
예제 #2
0
 /**
  * Test helper to reset testing data
  *
  * @return void
  */
 public function testHelperReset()
 {
     $test_transaction = $this->testHelperGet();
     if (!is_null($test_transaction)) {
         $this->em->remove($test_transaction);
         $this->em->flush();
     }
 }
 /**
  * Clears old webcode
  *
  * @param EntityManager $em            Entity Manager
  * @param string        $articleNumber Article
  *
  * @return void
  */
 private function clearWebcode($em, $articleNumber, $articleLanguage)
 {
     $webcode = $em->getRepository('Newscoop\\Entity\\Webcode')->createQueryBuilder('w')->leftJoin('w.article', 'a')->where('a.number = :number')->andWhere('a.language = :language')->setParameter('number', $articleNumber)->setParameter('language', $articleLanguage)->getQuery()->getOneOrNullResult();
     if ($webcode) {
         $em->remove($webcode);
         $em->flush();
     }
 }
예제 #4
0
 /**
  * Delete controller
  *
  * @param Request  $request
  * @param Response $response
  * @param array    $args
  *
  * @return Response
  */
 public function delete(Request $request, Response $response, array $args)
 {
     $entity = $this->em->getRepository($this->entityClass)->find($args['id']);
     if ($entity) {
         $this->em->remove($entity);
         $this->em->flush();
     }
     return new RedirectResponse($this->route);
 }
예제 #5
0
 /**
  * {@inheritDoc}
  */
 public function remove($content)
 {
     if (!is_array($content)) {
         $content = [$content];
     }
     $content = $this->getRepository()->findByIds($content);
     foreach ($content as $item) {
         $this->em->remove($item);
     }
     $this->em->flush();
 }
예제 #6
0
 public function testAuditable()
 {
     $user = new UserAudit("beberlei");
     $article = new ArticleAudit("test", "yadda!", $user, 'text');
     $this->em->persist($user);
     $this->em->persist($article);
     $this->em->flush();
     $this->assertEquals(1, count($this->em->getConnection()->fetchAll('SELECT id FROM revisions')));
     $this->assertEquals(1, count($this->em->getConnection()->fetchAll('SELECT * FROM UserAudit_audit')));
     $this->assertEquals(1, count($this->em->getConnection()->fetchAll('SELECT * FROM ArticleAudit_audit')));
     $article->setText("oeruoa");
     $this->em->flush();
     $this->assertEquals(2, count($this->em->getConnection()->fetchAll('SELECT id FROM revisions')));
     $this->assertEquals(2, count($this->em->getConnection()->fetchAll('SELECT * FROM ArticleAudit_audit')));
     $this->em->remove($user);
     $this->em->remove($article);
     $this->em->flush();
     $this->assertEquals(3, count($this->em->getConnection()->fetchAll('SELECT id FROM revisions')));
     $this->assertEquals(2, count($this->em->getConnection()->fetchAll('SELECT * FROM UserAudit_audit')));
     $this->assertEquals(3, count($this->em->getConnection()->fetchAll('SELECT * FROM ArticleAudit_audit')));
 }
예제 #7
0
 /**
  * Test helper to reset testing data
  *
  * @return void
  */
 public function testHelperReset()
 {
     $test_SubProject = $this->testHelperGet();
     if (!is_null($test_SubProject)) {
         $this->em->remove($test_SubProject);
         $this->em->flush();
     }
     $test_SubProject_2 = $this->repo->findOneByName('TestDelprosjekt2');
     if (!is_null($test_SubProject_2)) {
         $this->em->remove($test_SubProject_2);
         $this->em->flush();
     }
 }
예제 #8
0
 /**
  * Test helper to reset testing data
  *
  * @return void
  */
 public function testHelperReset()
 {
     $test_budget = $this->testHelperGet();
     if (!is_null($test_budget)) {
         $this->em->remove($test_budget);
         $this->em->flush();
     }
     $test_budget_2 = $this->repo->findOneByName('TestBudsjett2');
     if (!is_null($test_budget_2)) {
         $this->em->remove($test_budget_2);
         $this->em->flush();
     }
 }
예제 #9
0
 /**
  * @param integer $ownerId
  * @param integer $rootVersion
  */
 public function discardAll($ownerId)
 {
     $owner = $this->find($ownerId);
     if (!$owner instanceof BlockOwnerInterface) {
         throw new \Exception('Discard all changes is only possible on Block owners');
     }
     $this->killLoggableListener();
     $this->killSoftDeletableListener();
     $this->em->getRepository('OpiferContentBundle:BlockLogEntry')->discardAll($ownerId);
     if ($this->em->getFilters()->isEnabled('softdeleteable')) {
         $this->em->getFilters()->disable('softdeleteable');
     }
     $stubs = $this->getRepository()->findBy(['owner' => $owner, 'version' => 0]);
     foreach ($stubs as $stub) {
         $this->em->remove($stub);
     }
     $this->em->flush();
 }
예제 #10
0
 /**
  * Deletes a thread
  *
  * @param ThreadInterface $thread the thread to delete
  */
 public function deleteThread(ThreadInterface $thread)
 {
     $this->em->remove($thread);
     $this->em->flush();
 }
예제 #11
0
 /**
  * Remove a directory
  *
  * @param  DirectoryInterface $directory
  */
 public function remove(DirectoryInterface $directory)
 {
     $this->em->remove($directory);
     $this->em->flush();
 }
예제 #12
0
 /**
  * Delete a project
  *
  * @param Project $project
  */
 public function delete(Project $project)
 {
     $this->objectManager->remove($project);
     $this->objectManager->flush();
 }