/** * @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; }
/** * @param Projection $projection */ public function remove(Projection $projection) { $storedProjection = $this->repository->find($projection->getProjectionName() . '_' . $projection->getAggregateId()); if (!empty($storedProjection)) { $this->manager->remove($storedProjection); } }
function delete($entity, $flush = 1) { $this->dm->remove($entity); if (1 == $flush) { $this->dm->flush($entity); } }
/** * {@inheritdoc} */ public function deletePartner(PartnerInterface $partner, $andFlush = true) { $this->dm->remove($partner); if ($andFlush) { $this->dm->flush(); } }
public function remove($key) { $cache = $this->dm->getRepository('SGLiveChatBundle:CacheEntry')->getByKey($key); if ($cache) { $this->dm->remove($cache); } $this->dm->flush(); return true; }
/** * @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(); }
/** * @inheritdoc */ public function deleteFile($id) { $file = $this->getFile($id); if ($file === null) { return false; } $this->documentManager->remove($file); $this->documentManager->flush(); return true; }
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); } } }); }
/** * 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; }
/** * @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); }); }
/** * @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(); }
protected function truncate() { if ($this->list) { foreach ($this->list as $document) { $this->manager->remove($document); } $this->manager->flush(); } }
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); }
/** * @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)); }
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(); }
/** * @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(); }
/** * 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(); }
/** * @param Piece $piece */ public function delete(Piece $piece) { $this->documentManager->remove($piece); $this->flush(); }
/** * 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(); }
/** * {@inheritdoc} */ public function deleteAuthCode(AuthCodeInterface $authCode) { $this->dm->remove($authCode); $this->dm->flush(); }
/** * {@inheritdoc} */ public function deleteClient(ClientInterface $client) { $this->dm->remove($client); $this->dm->flush(); }
/** * {@inheritDoc} */ public function delete(CommentInterface $comment) { $this->dm->remove($comment); $this->dm->flush(); }
public function removeAttendee(AttendeeInterface $attendee) { $this->em->remove($attendee); $this->em->flush(); return true; }
/** * {@inheritdoc} */ public function deleteToken(TokenInterface $token) { $this->dm->remove($token); $this->dm->flush(); }
public function removeCalendar(CalendarInterface $calendar) { $this->em->remove($calendar); $this->em->flush(); return true; }
/** * {@inheritDoc} */ public function delete(PostInterface $post) { $this->dm->remove($post); $this->dm->flush(); }
function delete($entity) { $this->om->remove($entity); $this->om->flush(); return $entity; }
/** * 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(); }
public function removeEvent(EventInterface $event) { $this->em->remove($event); $this->em->flush(); return true; }
/** * {@inheritdoc} */ public function delete(AccessTokenEntity $token) { $accessToken = $this->dm->getRepository(AccessToken::class)->find($token->getId()); $this->dm->remove($accessToken); $this->dm->flush($accessToken); }