remove() public method

A removed document will be removed from the database at or before transaction commit or as a result of the flush operation.
public remove ( object $document )
$document object The document instance to remove.
コード例 #1
0
ファイル: ItemManager.php プロジェクト: halk/item-similarity
 /**
  * @param Item        $item
  * @param string|null $collection
  * @return Item
  */
 public function delete($item, $collection = null)
 {
     $this->setCollection($collection);
     $this->dm->remove($item);
     $this->dm->flush();
     return $item;
 }
コード例 #2
0
 /**
  * @param Projection $projection
  */
 public function remove(Projection $projection)
 {
     $storedProjection = $this->repository->find($projection->getProjectionName() . '_' . $projection->getAggregateId());
     if (!empty($storedProjection)) {
         $this->manager->remove($storedProjection);
     }
 }
コード例 #3
0
 function delete($entity, $flush = 1)
 {
     $this->dm->remove($entity);
     if (1 == $flush) {
         $this->dm->flush($entity);
     }
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function deletePartner(PartnerInterface $partner, $andFlush = true)
 {
     $this->dm->remove($partner);
     if ($andFlush) {
         $this->dm->flush();
     }
 }
コード例 #5
0
ファイル: Mongo.php プロジェクト: faridos/ServerGroveLiveChat
 public function remove($key)
 {
     $cache = $this->dm->getRepository('SGLiveChatBundle:CacheEntry')->getByKey($key);
     if ($cache) {
         $this->dm->remove($cache);
     }
     $this->dm->flush();
     return true;
 }
コード例 #6
0
ファイル: DocumentsTest.php プロジェクト: renatomefidf/sammui
 /**
  * @depends testLang
  * @param $lang
  */
 public function testTranslationDelete($lang)
 {
     $language = $this->documentManager->find(get_class($lang->language), $lang->language->getId());
     $translation = $this->documentManager->find(get_class($lang->translation), $lang->translation->getId());
     $language->removeTranslation($translation);
     $this->documentManager->flush();
     $this->documentManager->remove($translation);
     $this->documentManager->remove($language);
     $this->documentManager->flush();
 }
コード例 #7
0
 /**
  * @inheritdoc
  */
 public function deleteFile($id)
 {
     $file = $this->getFile($id);
     if ($file === null) {
         return false;
     }
     $this->documentManager->remove($file);
     $this->documentManager->flush();
     return true;
 }
コード例 #8
0
ファイル: Manager.php プロジェクト: cross-solution/yawik
 protected function attachDefaultListeners()
 {
     $this->getEventManager()->attach(static::EVENT_REMOVE_ITEMS, function (EventInterface $event) {
         $user = $event->getParam('user');
         foreach ($this->getLists() as $list) {
             foreach ($list->getEntities($user) as $entity) {
                 $this->documentManager->remove($entity);
             }
         }
     });
 }
コード例 #9
0
 /**
  * Remove single node
  *
  * @param  array $params
  * @return object
  *
  * @throws LogicException
  */
 public function remove($params)
 {
     if ($childId = $params['id']) {
         $node = $this->dm->getRepository($this->model)->find($childId);
         if (!$node) {
             throw new LogicException('Nothing found');
         }
     }
     $this->dm->remove($node);
     $this->dm->flush();
     return $node;
 }
コード例 #10
0
ファイル: Hive.php プロジェクト: 100hz/hive
 /**
  * @param \Hive\Resource $resource
  * @param string $uri
  * @param string $property
  */
 protected function setupDelete($resource, $uri = null, $property = null)
 {
     if ($uri === null) {
         $uri = $resource->settings['actions']['Delete']['uri'];
     }
     $this->klein->respond('DELETE', $uri, function ($request, $response, $service, $app) use($resource, $property) {
         /**
          * @var Request $request
          * @var Response $response
          * @var ServiceProvider $service
          * @var App $app
          */
         $resourceRequest = ResourceRequest::create('Delete', $resource, $request, $response, $service, $app, $property);
         if (!call_user_func($resource->allowRequest, $resourceRequest)) {
             return false;
         }
         $result = call_user_func($resource->findOne, $resourceRequest);
         if ($result === null) {
             throw $this->createHttpException(404);
         }
         $this->dm->remove($result);
         $this->dm->flush();
         return call_user_func($resource->renderResult, $resourceRequest, $result);
     });
 }
コード例 #11
0
 /**
  * @depends testCreateProtocol
  * @depends testDeleteUpload
  */
 public function testDeleteProtocol(Protocol $protocol)
 {
     $forms = $this->dm->getRepository('FormBundle:Form')->findByName($protocol->getForm()->getName());
     foreach ($forms as $form) {
         $this->dm->remove($form);
     }
     $this->dm->flush();
 }
コード例 #12
0
 protected function truncate()
 {
     if ($this->list) {
         foreach ($this->list as $document) {
             $this->manager->remove($document);
         }
         $this->manager->flush();
     }
 }
コード例 #13
0
ファイル: APIVersion1.php プロジェクト: graymur/tw-react
 public function deleteAction(Application $app, $model, $id)
 {
     $model = $this->checkModel($model);
     if (!($item = $this->dm->getRepository($model)->find(new \MongoId($id)))) {
         throw new \Exception();
     }
     $this->dm->remove($item);
     $this->dm->flush();
     return $app->json(array('id' => $item->id), 204);
 }
コード例 #14
0
ファイル: DefaultController.php プロジェクト: jlaso/tradukoj
 /**
  * @Route("/normalize/{projectId}/{erase}", name="normalize")
  * @ Method("POST")
  * @ParamConverter("project", class="TranslationsBundle:Project", options={"id" = "projectId"})
  */
 public function normalizeAction(Request $request, Project $project, $erase = '')
 {
     $this->init();
     // completar los documentos  a los que le falten subdocumentos de traducciones
     //$this->translationsManager->userHasProject($this->user, $project);
     $permissions = $this->translationsManager->getPermissionForUserAndProject($this->user, $project);
     $permissions = $permissions->getPermissions();
     if ($permissions['general'] != Permission::OWNER) {
         return $this->printResult(array('result' => false, 'reason' => 'not enough permissions to do this'));
     }
     $managedLocales = explode(',', $project->getManagedLocales());
     /** @var Translation[] $translations */
     $translations = $this->getTranslationRepository()->findBy(array('projectId' => $project->getId()));
     $normalized = array();
     foreach ($translations as $translation) {
         $bundle = "";
         $transArray = $translation->getTranslations();
         foreach ($managedLocales as $locale) {
             if (!isset($transArray[$locale])) {
                 $transArray[$locale] = Translation::genTranslationItem('');
                 $normalized[] = $translation->getKey() . "[{$locale}]";
             } else {
                 if (!$bundle && isset($transArray[$locale]['fileName']) && $transArray[$locale]['fileName']) {
                     if (preg_match("@/(?<bundle>\\w*?Bundle)/@", $transArray[$locale]['fileName'], $match)) {
                         $bundle = $match['bundle'];
                     } else {
                         if (preg_match("@/app/@", $transArray[$locale]['fileName'])) {
                             $bundle = "app*";
                         }
                     }
                 }
             }
         }
         if ($bundle && !$translation->getBundle()) {
             $normalized[] = $translation->getKey() . " -> " . $bundle;
             $translation->setBundle($bundle);
         }
         $translation->setTranslations($transArray);
         $this->dm->persist($translation);
     }
     $this->dm->flush();
     if ($erase === 'erase-duplicates') {
         // eliminar los documentos que no tengan translation en ingles (para borrar duplicados)
         foreach ($translations as $translation) {
             $transArray = $translation->getTranslations();
             if (!$transArray['en']['message']) {
                 print 'erasing ... ' . $translation->getId() . '<br/>';
                 $this->dm->remove($translation);
             }
         }
         $this->dm->flush();
     }
     return $this->printResult(array('result' => true, 'normalized' => $normalized));
 }
コード例 #15
0
ファイル: Document.php プロジェクト: sxn/DataGridBundle
 public function delete(array $ids)
 {
     $repository = $this->manager->getRepository($this->documentName);
     foreach ($ids as $id) {
         $object = $repository->find($id);
         if (!$object) {
             throw new \Exception(sprintf('No %s found for id %s', $this->documentName, $id));
         }
         $this->manager->remove($object);
     }
     $this->manager->flush();
 }
コード例 #16
0
 /**
  * @depends testFormNew
  * @depends testGetProtocolNotFound
  * @depends testGetProtocol
  * @depends testGetProtocolsByForm
  * @depends testProtocolAddComment
  * @depends testProtocolRemoveComment
  * @depends testProtocolConclusion
  */
 public function testDeleteForm()
 {
     $formRepo = $this->dm->getRepository('FormBundle:Form');
     $forms = $formRepo->findByName(static::$formName);
     if (count($forms) < 1) {
         return;
     }
     foreach ($forms as $form) {
         $this->dm->remove($form);
     }
     $this->dm->flush();
 }
コード例 #17
0
ファイル: DocumentsTest.php プロジェクト: renatomefidf/sammui
 /**
  * Test Protocol Comment embed Document
  */
 public function testProtocolComment()
 {
     $protocolComment = new ProtocolComment();
     $protocolComment->setBody('test');
     $this->documentManager->persist($protocolComment);
     $this->documentManager->flush();
     $this->assertNotEmpty($protocolComment->getId());
     $this->assertNotEmpty($protocolComment->getCreatedAt());
     $this->assertNotEmpty($protocolComment->getBody());
     $this->documentManager->remove($protocolComment);
     $this->documentManager->flush();
 }
コード例 #18
0
ファイル: PieceManager.php プロジェクト: jahller/streetartlas
 /**
  * @param Piece $piece
  */
 public function delete(Piece $piece)
 {
     $this->documentManager->remove($piece);
     $this->flush();
 }
コード例 #19
0
 /**
  * Deletes a thread
  * This is not participant deletion but real deletion
  *
  * @param ThreadInterface $thread the thread to delete
  */
 public function deleteThread(ThreadInterface $thread)
 {
     $this->dm->remove($thread);
     $this->dm->flush();
 }
コード例 #20
0
 /**
  * {@inheritdoc}
  */
 public function deleteAuthCode(AuthCodeInterface $authCode)
 {
     $this->dm->remove($authCode);
     $this->dm->flush();
 }
コード例 #21
0
 /**
  * {@inheritdoc}
  */
 public function deleteClient(ClientInterface $client)
 {
     $this->dm->remove($client);
     $this->dm->flush();
 }
コード例 #22
0
 /**
  * {@inheritDoc}
  */
 public function delete(CommentInterface $comment)
 {
     $this->dm->remove($comment);
     $this->dm->flush();
 }
コード例 #23
0
 public function removeAttendee(AttendeeInterface $attendee)
 {
     $this->em->remove($attendee);
     $this->em->flush();
     return true;
 }
コード例 #24
0
 /**
  * {@inheritdoc}
  */
 public function deleteToken(TokenInterface $token)
 {
     $this->dm->remove($token);
     $this->dm->flush();
 }
コード例 #25
0
 public function removeCalendar(CalendarInterface $calendar)
 {
     $this->em->remove($calendar);
     $this->em->flush();
     return true;
 }
コード例 #26
0
 /**
  * {@inheritDoc}
  */
 public function delete(PostInterface $post)
 {
     $this->dm->remove($post);
     $this->dm->flush();
 }
コード例 #27
0
 function delete($entity)
 {
     $this->om->remove($entity);
     $this->om->flush();
     return $entity;
 }
コード例 #28
0
ファイル: BaseManager.php プロジェクト: TWEagle/warden
 /**
  * Delete the Mongodb document.
  *
  * @param int $id
  *   The Mongodb Object Id.
  */
 public function deleteDocument($id)
 {
     $document = $this->getDocumentById($id);
     $this->doctrineManager->remove($document);
     $this->doctrineManager->flush();
 }
コード例 #29
0
ファイル: EventManager.php プロジェクト: pguso/CalendarBundle
 public function removeEvent(EventInterface $event)
 {
     $this->em->remove($event);
     $this->em->flush();
     return true;
 }
コード例 #30
0
 /**
  * {@inheritdoc}
  */
 public function delete(AccessTokenEntity $token)
 {
     $accessToken = $this->dm->getRepository(AccessToken::class)->find($token->getId());
     $this->dm->remove($accessToken);
     $this->dm->flush($accessToken);
 }