public function remove(TestSuiteInterface $test_suite, $flush = true) { $this->object_manager->remove($test_suite); if ($flush) { $this->object_manager->flush(); } }
protected function cleanDatabase() { foreach ($this->repository->findStatements(array()) as $statement) { $this->objectManager->remove($statement); } $this->objectManager->flush(); }
public function syncCronjobs() { $dbCronjobs = $this->getDatabaseCronjobs(); foreach ($this->configCronjobs as $jobId => $job) { if (!isset($dbCronjobs[$jobId])) { $cronjob = $this->createCronjob(); $cronjob->setId($jobId); $this->om->persist($cronjob); $dbCronjobs[$jobId] = $cronjob; } else { $cronjob = $dbCronjobs[$jobId]; } $cronjob->setCommand($job['command']); $cronjob->setArguments($job['arguments']); $cronjob->setCronExpression($job['expression']); $cronjob->setExecuteTimeout($job['execute_timeout']); $cronjob->setLogFile($job['log_file']); } $i = 0; foreach ($dbCronjobs as $job_id => $cronjob) { if (!isset($this->configCronjobs[$job_id])) { if (!$cronjob->isLocked()) { $this->om->remove($cronjob); unset($dbCronjobs[$job_id]); } } else { $cronjob->setPriority($i++); } } $this->om->flush(); }
/** * {@inheritdoc} */ protected function doDelete($object, $flush = true) { $this->manager->remove($object); if ($flush) { $this->flush($object); } }
/** * Delete resource * * @param mixed $id Id * * @return void */ public function delete($id) { if ($object = $this->fetch($id)) { $this->objectManager->remove($object); $this->objectManager->flush(); } }
/** * @param ResourceEvent $resourceEvent */ public function onSave(ResourceEvent $resourceEvent) { // var_dump($resourceEvent); // $module = $resourceEvent->getContainer()->getModule(); $entities = $this->moduleRepository->setClass(new ResourceRepository())->findByAllResources(); $entitiesToRemove = $this->objectManager->getRepository("BigfishCoreBundle:CacheRouting")->findAll(); $flush = false; foreach ($entitiesToRemove as $remove) { $this->objectManager->remove($remove); $flush = true; } if ($flush) { $this->objectManager->flush(); } $flush = false; foreach ($entities as $entity) { if (isset($entity["resource_id"])) { // $resource = $this->objectManager->getRepository("BigfishCoreBundle:Resource")->find($entity["resource_id"]); if ($resource) { $routeData = $this->getParentsEntities($entities, $entity["resource_id"]); $route = new CacheRouting(); $route->setResource($resource); $route->setLanguage($this->languageManager->getObject()); $path = $this->validateSlug($entity["routerPath"], $routeData); $route->setPath($path); $this->objectManager->persist($route); $flush = true; } } } if ($flush) { $this->objectManager->flush(); } }
/** * @param Attachment $attachment * @param array $dimensionIds * * @return ImageInstance */ public function create(Attachment $attachment, DimensionContainer $dimensionContainer) { $validate = $this->constraints->getConstraints($attachment, $dimensionContainer); if ($validate) { $fs = new Filesystem(); $fs->remove(sprintf('%s/%s', $this->tempPath, $attachment->getFile())); $fs->remove(sprintf('%s/%s', $this->uploadPath, $attachment->getFile())); $this->objectManager->remove($attachment); $this->objectManager->flush(); return $validate; } $instance = new ImageInstance(); $instance->setName($attachment->getName()); $this->objectManager->persist($instance); foreach ($dimensionContainer->getDimensions() as $dimension) { $cropping = new ImageCropping(); $cropping->setAttachment($attachment); $cropping->setInstance($instance); $cropping->setDimension($dimension); $cropping->setName($attachment->getName()); $this->objectManager->persist($cropping); } $this->objectManager->flush(); return $instance; }
/** * @param LocationModel $location * @param bool $withFlush */ public function delete(LocationModel $location, $withFlush = true) { $this->objectManager->remove($location); if ($withFlush) { $this->objectManager->flush(); } }
/** * {@inheritdoc} */ public function remove($object, array $options = []) { if (!$object instanceof SequentialEdit) { throw new \InvalidArgumentException(sprintf('Expects a Pim\\Bundle\\EnrichBundle\\Entity\\SequentialEdit, "%s" provided', ClassUtils::getClass($object))); } $this->om->remove($object); $this->om->flush($object); }
/** * {@inheritdoc} */ public function remove($object, array $options = []) { if (false === $object instanceof $this->removedClass) { throw new \InvalidArgumentException(sprintf('Expects a "%s", "%s" provided.', $this->removedClass, ClassUtils::getClass($object))); } $this->objectManager->remove($object); $this->objectManager->flush(); }
/** * Prune old instance of simple mapping for the given identifier. * * @param string $identifier */ protected function pruneOldMapping($identifier) { $oldMappingItems = $this->getEntityRepository()->findBy(array('identifier' => $identifier)); foreach ($oldMappingItems as $oldMappingItem) { $this->objectManager->remove($oldMappingItem); } $this->objectManager->flush(); }
/** * @param Post $post * @throws UnauthorizedException */ public function delete(Post $post) { if (!$this->authorizationService->isGranted(self::DELETE)) { throw new UnauthorizedException(); } $this->objectManager->remove($post); $this->objectManager->flush(); }
public function delete(Recipe $recipe) { if (false === $this->authorizationService->isGranted('recipe.manage', $recipe)) { throw new UnauthorizedException('Insufficient Permissions'); } $this->objectManager->remove($recipe); $this->objectManager->flush(); }
/** * Create thread since intervention * @param InterventionEvent $event */ public function deleteThread(InterventionEvent $event) { $entity = $event->getIntervention(); $starter = $this->om->getRepository('JLMFollowBundle:StarterIntervention')->findOneBy(array('intervention' => $entity)); $thread = $this->om->getRepository('JLMFollowBundle:Thread')->findOneBy(array('starter' => $starter)); $this->om->remove($thread); $this->om->remove($starter); $this->om->flush(); }
/** * Create work since intervention * @param InterventionEvent $event */ public function deleteWorkFromIntervention(InterventionEvent $event) { $interv = $event->getIntervention(); $work = $interv->getWork(); $interv->setWork(); $this->om->remove($work); $this->om->persist($interv); $this->om->flush(); }
/** * @param ReviewInterface $review * @param ReviewableInterface[] $reviewSubjectsToRecalculate * * @return array */ private function removeReviewsAndExtractSubject(ReviewInterface $review, array $reviewSubjectsToRecalculate) { $reviewSubject = $review->getReviewSubject(); if (!in_array($reviewSubject, $reviewSubjectsToRecalculate)) { $reviewSubjectsToRecalculate[] = $reviewSubject; } $this->reviewManager->remove($review); return $reviewSubjectsToRecalculate; }
/** * Deletes a model. * * @param mixed $model Model to save * @param bool $sync Synchronize directly with database * * @throws \RuntimeException */ public function delete($model, $sync = false) { if (!$model instanceof $this->class) { throw new \RuntimeException(sprintf('Manager "%s" is unable to delete model "%s"', get_class($this), get_class($model))); } $this->manager->remove($model); if ($sync) { $this->manager->flush(); } }
/** * @param AccessToken $accessTokenObject * @return bool * @throws \Exception */ public function delete(AccessToken $accessTokenObject) { try { $this->objectManager->remove($accessTokenObject); $this->objectManager->flush(); return true; } catch (\Exception $e) { throw new \Exception($e); } }
/** * {@inheritdoc} */ public function remove($object, array $options = []) { if (!$object instanceof DatagridView) { throw new \InvalidArgumentException(sprintf('Expects a Pim\\Bundle\\DataGridBundle\\Entity\\DatagridView, "%s" provided', ClassUtils::getClass($object))); } $options = array_merge(['flush' => true], $options); $this->objectManager->remove($object); if (true === $options['flush']) { $this->objectManager->flush(); } }
/** * {@inheritdoc} */ public function remove($object, array $options = []) { if (!$object instanceof CommentInterface) { throw new \InvalidArgumentException(sprintf('Expects a use Pim\\Bundle\\CommentBundle\\Model\\CommentInterface, "%s" provided', ClassUtils::getClass($object))); } $options = array_merge(['flush' => true], $options); $this->objectManager->remove($object); if (true === $options['flush']) { $this->objectManager->flush(); } }
/** * {@inheritdoc} */ public function remove($stripeId, $flush = false) { if ($model = $this->retrieve($stripeId)) { $this->objectManager->remove($model); if ($flush) { $this->objectManager->flush($model); } return true; } return false; }
/** * Remove deleted files * * @param DataEvent $event */ public function postBind(DataEvent $event) { $collection = $event->getData(); if ($collection instanceof PersistentCollection) { foreach ($collection->getDeleteDiff() as $entity) { if ($entity instanceof MultiFileInterface) { $this->om->remove($entity); } } } }
/** * Purge existing OrderCoupons * * @param OrderInterface $order Order where to delete all coupons * * @return $this Self object */ public function truncateOrderCoupons(OrderInterface $order) { $orderCoupons = $this->orderCouponRepository->findOrderCouponsByOrder($order); if ($orderCoupons instanceof Collection) { foreach ($orderCoupons as $orderCoupon) { $this->orderCouponObjectManager->remove($orderCoupon); } $this->orderCouponObjectManager->flush($orderCoupons->toArray()); } return $this; }
public function release($name) { $nameWithPrefix = $this->getNameWithPrefix($name); $lock = $this->repository->findOneBy(['name' => $nameWithPrefix]); if ($lock) { $this->objectManager->remove($lock); $this->objectManager->flush(); return true; } return false; }
/** * {@inheritdoc} */ public function remove($group, array $options = []) { if (!$group instanceof GroupInterface) { throw new \InvalidArgumentException(sprintf('Expects an "%s", "%s" provided.', 'Pim\\Bundle\\CatalogBundle\\Model\\GroupInterface', ClassUtils::getClass($group))); } $options = $this->optionsResolver->resolveRemoveOptions($options); $this->eventDispatcher->dispatch(GroupEvents::PRE_REMOVE, new GenericEvent($group)); $this->objectManager->remove($group); if (true === $options['flush']) { $this->objectManager->flush(); } }
/** * {@inheritdoc} */ public function remove($object, array $options = []) { if (!$object instanceof $this->removedClass) { throw new \InvalidArgumentException(sprintf('Expects a "%s", "%s" provided.', $this->removedClass, ClassUtils::getClass($object))); } $options = $this->optionsResolver->resolveRemoveOptions($options); $this->objectManager->remove($object); if (true === $options['flush'] && true === $options['flush_only_object']) { $this->objectManager->flush($object); } elseif (true === $options['flush']) { $this->objectManager->flush(); } }
/** * Remove an attribute from product template * * @param AttributeInterface $attribute */ protected function removeFromProductTemplate(AttributeInterface $attribute) { if (null === $this->productTplBuilder || null === $this->productTplRepository) { return; } foreach ($this->productTplRepository->findAll() as $productTemplate) { if ($productTemplate->hasValueForAttribute($attribute)) { $this->productTplBuilder->removeAttribute($productTemplate, $attribute); $attributeCodes = $productTemplate->getAttributeCodes(); empty($attributeCodes) ? $this->objectManager->remove($productTemplate) : $this->objectManager->persist($productTemplate); } } }
/** * @param array $ratioList */ public function saveRatioList($ratioList) { $doctrineStorageRatios = $this->objectManager->getRepository('Tbbc\\MoneyBundle\\Entity\\DoctrineStorageRatio')->findAll(); foreach ($doctrineStorageRatios as $doctrineStorageRatio) { $this->objectManager->remove($doctrineStorageRatio); } $this->objectManager->flush(); foreach ($ratioList as $currencyCode => $ratio) { $this->objectManager->persist(new DoctrineStorageRatio($currencyCode, $ratio)); } $this->objectManager->flush(); $this->objectManager->clear(); $this->ratioList = $ratioList; }
/** * {@inheritdoc} */ public function remove($object, array $options = []) { if (!$object instanceof $this->removedClass) { throw new \InvalidArgumentException(sprintf('Expects a "%s", "%s" provided.', $this->removedClass, ClassUtils::getClass($object))); } $options = $this->optionsResolver->resolveRemoveOptions($options); $objectId = $object->getId(); $this->eventDispatcher->dispatch(StorageEvents::PRE_REMOVE, new RemoveEvent($object, $objectId, $options)); $this->objectManager->remove($object); if (true === $options['flush']) { $this->objectManager->flush(); } $this->eventDispatcher->dispatch(StorageEvents::POST_REMOVE, new RemoveEvent($object, $objectId, $options)); }
/** * {@inheritdoc} */ public function remove($attributeOption, array $options = []) { if (!$attributeOption instanceof AttributeOptionInterface) { throw new \InvalidArgumentException(sprintf('Expects an "%s", "%s" provided.', 'Pim\\Bundle\\CatalogBundle\\Model\\AttributeOptionInterface', ClassUtils::getClass($attributeOption))); } $options = $this->optionsResolver->resolveRemoveOptions($options); $attributeOptionId = $attributeOption->getId(); $this->eventDispatcher->dispatch(AttributeOptionEvents::PRE_REMOVE, new RemoveEvent($attributeOption, $attributeOptionId)); $this->objectManager->remove($attributeOption); if (true === $options['flush']) { $this->objectManager->flush(); } $this->eventDispatcher->dispatch(AttributeOptionEvents::POST_REMOVE, new RemoveEvent($attributeOption, $attributeOptionId)); }