本文整理汇总了PHP中Doctrine\Common\Persistence\ObjectManager::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::remove方法的具体用法?PHP ObjectManager::remove怎么用?PHP ObjectManager::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove
public function remove(TestSuiteInterface $test_suite, $flush = true)
{
$this->object_manager->remove($test_suite);
if ($flush) {
$this->object_manager->flush();
}
}
示例2: cleanDatabase
protected function cleanDatabase()
{
foreach ($this->repository->findStatements(array()) as $statement) {
$this->objectManager->remove($statement);
}
$this->objectManager->flush();
}
示例3: syncCronjobs
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();
}
示例4: doDelete
/**
* {@inheritdoc}
*/
protected function doDelete($object, $flush = true)
{
$this->manager->remove($object);
if ($flush) {
$this->flush($object);
}
}
示例5: delete
/**
* Delete resource
*
* @param mixed $id Id
*
* @return void
*/
public function delete($id)
{
if ($object = $this->fetch($id)) {
$this->objectManager->remove($object);
$this->objectManager->flush();
}
}
示例6: onSave
/**
* @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();
}
}
示例7: create
/**
* @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;
}
示例8: delete
/**
* @param LocationModel $location
* @param bool $withFlush
*/
public function delete(LocationModel $location, $withFlush = true)
{
$this->objectManager->remove($location);
if ($withFlush) {
$this->objectManager->flush();
}
}
示例9: remove
/**
* {@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);
}
示例10: remove
/**
* {@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();
}
示例11: pruneOldMapping
/**
* 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();
}
示例12: delete
/**
* @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();
}
示例13: delete
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();
}
示例14: deleteThread
/**
* 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();
}
示例15: deleteWorkFromIntervention
/**
* 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();
}