当前位置: 首页>>代码示例>>PHP>>正文


PHP ObjectManager::flush方法代码示例

本文整理汇总了PHP中Claroline\CoreBundle\Persistence\ObjectManager::flush方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::flush方法的具体用法?PHP ObjectManager::flush怎么用?PHP ObjectManager::flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Claroline\CoreBundle\Persistence\ObjectManager的用法示例。


在下文中一共展示了ObjectManager::flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: chapter

 public function chapter($title, $text, $lesson, $root)
 {
     $chapter = new Chapter();
     $chapter->setTitle($title);
     $chapter->setText($text);
     $chapter->setLesson($lesson);
     $this->om->persist($chapter);
     $this->om->flush();
     return $chapter;
 }
开发者ID:claroline,项目名称:distribution,代码行数:10,代码来源:Persister.php

示例2: testDeleteCategoryNotAllowed

 public function testDeleteCategoryNotAllowed()
 {
     $john = $this->persist->user('john');
     $jane = $this->persist->user('jane');
     $simupoll = $this->persist->simupoll('simupoll1', $john);
     $category = $this->persist->category('category1', $john, $simupoll);
     $this->om->flush();
     $this->request('DELETE', "/simupoll/category/delete/{$category->getId()}", $jane);
     $this->assertEquals(403, $this->client->getResponse()->getStatusCode());
 }
开发者ID:CPASimUSante,项目名称:Simupoll,代码行数:10,代码来源:CategoryControllerTest.php

示例3: viewHint

 /**
  * Returns the contents of a hint and records a log asserting that the hint
  * has been consulted for a given paper.
  *
  * @param Paper $paper
  * @param Hint  $hint
  *
  * @return string
  */
 public function viewHint(Paper $paper, Hint $hint)
 {
     $log = $this->om->getRepository('UJMExoBundle:LinkHintPaper')->findOneBy(['paper' => $paper, 'hint' => $hint]);
     if (!$log) {
         $log = new LinkHintPaper($hint, $paper);
         $this->om->persist($log);
         $this->om->flush();
     }
     return $hint->getValue();
 }
开发者ID:claroline,项目名称:distribution,代码行数:19,代码来源:HintManager.php

示例4: deleteSubscriptions

 /**
  * Delete all Subscriptions of an Exercise.
  *
  * @param Exercise $exercise
  * @param bool     $flush
  *
  * @return SubscriptionManager
  */
 public function deleteSubscriptions(Exercise $exercise, $flush = false)
 {
     $subscriptions = $this->om->getRepository('UJMExoBundle:Subscription')->findByExercise($exercise);
     foreach ($subscriptions as $subscription) {
         $this->om->remove($subscription);
     }
     if ($flush) {
         $this->om->flush();
     }
     return $this;
 }
开发者ID:claroline,项目名称:distribution,代码行数:19,代码来源:SubscriptionManager.php

示例5: updateDefaultPerms

 public function updateDefaultPerms()
 {
     $tools = array(array('home', false, true), array('parameters', true, true), array('resource_manager', false, true), array('agenda', false, true), array('logs', false, true), array('analytics', false, true), array('users', false, true), array('badges', false, true));
     $this->log('updating tools...');
     foreach ($tools as $tool) {
         $entity = $this->om->getRepository('ClarolineCoreBundle:Tool\\Tool')->findOneByName($tool[0]);
         if ($entity) {
             $entity->setIsLockedForAdmin($tool[1]);
             $entity->setIsAnonymousExcluded($tool[2]);
             $this->om->persist($entity);
         }
     }
     $this->log('updating resource types...');
     $resourceTypes = $this->om->getRepository('ClarolineCoreBundle:Resource\\ResourceType')->findAll();
     foreach ($resourceTypes as $resourceType) {
         $resourceType->setDefaultMask(1);
         $this->om->persist($resourceType);
     }
     $this->om->flush();
     $this->log('updating manager roles...');
     $this->log('this may take a while...');
     $managerRoles = $this->om->getRepository('ClarolineCoreBundle:Role')->searchByName('ROLE_WS_MANAGER');
     foreach ($managerRoles as $role) {
         $this->conn->query("DELETE FROM claro_ordered_tool_role\n                WHERE role_id = {$role->getId()}");
     }
     $this->log('updating resource rights...');
     $this->log('removing administrator rights...');
     $roleAdmin = $this->om->getRepository('ClarolineCoreBundle:Role')->findOneByName('ROLE_ADMIN');
     $adminRights = $this->om->getRepository('ClarolineCoreBundle:Resource\\ResourceRights')->findBy(array('role' => $roleAdmin));
     foreach ($adminRights as $adminRight) {
         $this->om->remove($adminRight);
     }
     $this->om->flush();
     $this->log('adding user rights... ');
     $this->log('it may take a while...');
     $resourceNodes = $this->om->getRepository('ClarolineCoreBundle:Resource\\ResourceNode')->findAll();
     $roleUser = $this->om->getRepository('ClarolineCoreBundle:Role')->findOneByName('ROLE_USER');
     $this->om->startFlushSuite();
     $i = 0;
     foreach ($resourceNodes as $resourceNode) {
         $rightsManager = $this->container->get('claroline.manager.rights_manager');
         $rightsManager->create(0, $roleUser, $resourceNode, false);
         $i++;
         if ($i % 200 === 0) {
             $this->om->endFlushSuite();
             $this->om->startFlushSuite();
         }
     }
     $this->om->endFlushSuite();
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:50,代码来源:Updater021000.php

示例6: postUpdate

 public function postUpdate()
 {
     $coreIconWebDirRelativePath = "bundles/clarolinecore/images/resources/icons/";
     $images = array(array('res_mspowerpoint.png', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'), array('res_msword.png', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'));
     $this->log('Adding new resource icons...');
     foreach ($images as $image) {
         $rimg = new ResourceIcon();
         $rimg->setRelativeUrl($coreIconWebDirRelativePath . $image[0]);
         $rimg->setMimeType($image[1]);
         $rimg->setShortcut(false);
         $this->objectManager->persist($rimg);
         $this->container->get('claroline.manager.icon_manager')->createShortcutIcon($rimg);
     }
     $this->objectManager->flush();
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:15,代码来源:Updater021201.php

示例7: updateMetadata

 /**
  * Update the Exercise metadata.
  *
  * @param Exercise  $exercise
  * @param \stdClass $metadata
  *
  * @throws ValidationException
  */
 public function updateMetadata(Exercise $exercise, \stdClass $metadata)
 {
     $errors = $this->validator->validateExerciseMetadata($metadata);
     if (count($errors) > 0) {
         throw new ValidationException('Exercise metadata are not valid', $errors);
     }
     // Update ResourceNode
     $node = $exercise->getResourceNode();
     $node->setName($metadata->title);
     // Update Exercise
     $exercise->setDescription($metadata->description);
     $exercise->setType($metadata->type);
     $exercise->setPickSteps($metadata->pick ? $metadata->pick : 0);
     $exercise->setShuffle($metadata->random);
     $exercise->setKeepSteps($metadata->keepSteps);
     $exercise->setMaxAttempts($metadata->maxAttempts);
     $exercise->setLockAttempt($metadata->lockAttempt);
     $exercise->setDispButtonInterrupt($metadata->dispButtonInterrupt);
     $exercise->setMetadataVisible($metadata->metadataVisible);
     $exercise->setMarkMode($metadata->markMode);
     $exercise->setCorrectionMode($metadata->correctionMode);
     $exercise->setAnonymous($metadata->anonymous);
     $exercise->setDuration($metadata->duration);
     $exercise->setStatistics($metadata->statistics ? true : false);
     $exercise->setMinimalCorrection($metadata->minimalCorrection ? true : false);
     $correctionDate = null;
     if (!empty($metadata->correctionDate) && CorrectionMode::AFTER_DATE === $metadata->correctionMode) {
         $correctionDate = \DateTime::createFromFormat('Y-m-d\\TH:i:s', $metadata->correctionDate);
     }
     $exercise->setDateCorrection($correctionDate);
     // Save to DB
     $this->om->persist($exercise);
     $this->om->flush();
 }
开发者ID:claroline,项目名称:distribution,代码行数:42,代码来源:ExerciseManager.php

示例8: postUpdate

 public function postUpdate()
 {
     $installedBundles = $this->container->getParameter('kernel.bundles');
     if (isset($installedBundles['IcapPortfolioBundle'])) {
         $icapPortfolioPlugin = $this->om->getRepository('ClarolineCoreBundle:Plugin')->findOneByBundleFQCN($installedBundles['IcapPortfolioBundle']);
         if (null === $icapPortfolioPlugin) {
             $this->log('    Creation of Portfolio plugin in database.');
             $icapPortfolioPlugin = new Plugin();
             $icapPortfolioPlugin->setVendorName('Icap');
             $icapPortfolioPlugin->setBundleName('PortfolioBundle');
             $icapPortfolioPlugin->setHasOptions(false);
             $this->om->persist($icapPortfolioPlugin);
             $this->om->flush();
         }
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:16,代码来源:Updater040804.php

示例9: deactivatePersonalWorkspaceRightsPerm

 public function deactivatePersonalWorkspaceRightsPerm(Role $role)
 {
     $access = $this->getPwsRightsManagementAccess($role);
     $access->setIsAccessible(false);
     $this->om->persist($access);
     $this->om->flush();
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:7,代码来源:RightsManager.php

示例10: load

 public function load(ObjectManager $manager)
 {
     $repository = $manager->getRepository('Claroline\\CoreBundle\\Entity\\ContentTranslation');
     //mails
     $frTitle = 'Inscription à %platform_name%';
     $frContent = "<div>Votre nom d'utilisateur est %username%</div></br>";
     $frContent .= "<div>Votre mot de passe est %password%</div>";
     $frContent .= "<div>%validation_mail%</div>";
     $enTitle = 'Registration to %platform_name%';
     $enContent = "<div>You username is %username%</div></br>";
     $enContent .= "<div>Your password is %password%</div>";
     $enContent .= "<div>%validation_mail%</div>";
     $type = 'claro_mail_registration';
     $content = new Content();
     $content->setTitle($enTitle);
     $content->setContent($enContent);
     $content->setType($type);
     $repository->translate($content, 'title', 'fr', $frTitle);
     $repository->translate($content, 'content', 'fr', $frContent);
     $manager->persist($content);
     //layout
     $frLayout = '<div></div>%content%<div></hr>Powered by %platform_name%</div>';
     $enLayout = '<div></div>%content%<div></hr>Powered by %platform_name%</div>';
     $layout = new Content();
     $layout->setContent($enLayout);
     $layout->setType('claro_mail_layout');
     $repository->translate($layout, 'content', 'fr', $frLayout);
     $manager->persist($layout);
     $manager->flush();
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:30,代码来源:LoadContentData.php

示例11: refresh

 public function refresh(ResourceIcon $icon)
 {
     $shortcut = $icon->getShortcutIcon();
     $newUrl = $this->createShortcutFromRelativeUrl($icon->getRelativeUrl());
     $shortcut->setRelativeUrl($newUrl);
     $this->om->persist($shortcut);
     $this->om->flush();
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:8,代码来源:IconManager.php

示例12: updatePersonalWorkspaceResourceRightsConfig

 private function updatePersonalWorkspaceResourceRightsConfig(ObjectManager $manager)
 {
     $roleUser = $manager->getRepository('ClarolineCoreBundle:Role')->findOneByName('ROLE_USER');
     $config = new PwsRightsManagementAccess();
     $config->setRole($roleUser);
     $config->setIsAccessible(true);
     $manager->persist($config);
     $manager->flush();
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:9,代码来源:LoadToolsData.php

示例13: closePaper

 /**
  * Close a Paper that is not finished (because the Exercise does not allow interruption).
  *
  * @param Paper $paper
  */
 public function closePaper(Paper $paper)
 {
     if (!$paper->getEnd()) {
         $paper->setEnd(new \DateTime());
     }
     $paper->setInterupt(true);
     // keep track that the user has not finished
     $paper->setScore($this->calculateScore($paper->getId()));
     $this->om->flush();
     $this->checkPaperEvaluated($paper);
 }
开发者ID:claroline,项目名称:distribution,代码行数:16,代码来源:PaperManager.php

示例14: load

 public function load(ObjectManager $manager)
 {
     $tools = array(array('platform_parameters', 'cog'), array('user_management', 'user'), array('workspace_management', 'book'), array('registration_to_workspace', 'book'), array('platform_packages', 'wrench'), array('desktop_and_home', 'home'), array('desktop_tools', 'pencil'), array('platform_logs', 'bars'), array('platform_analytics', 'bar-chart-o'), array('roles_management', 'users'), array('widgets_management', 'list-alt'));
     foreach ($tools as $tool) {
         $entity = new AdminTool();
         $entity->setName($tool[0]);
         $entity->setClass($tool[1]);
         $manager->persist($entity);
     }
     $manager->flush();
 }
开发者ID:ChMat,项目名称:CoreBundle,代码行数:11,代码来源:LoadAdminToolsData.php

示例15: postUpdate

 public function postUpdate()
 {
     $this->log('Updating cache...');
     $this->container->get('claroline.manager.cache_manager')->refresh();
     $this->log('Removing old cache...');
     if (file_exists($this->oldCachePath)) {
         unlink($this->oldCachePath);
     }
     $this->log('Creating admin tools...');
     $tools = array(array('platform_parameters', 'icon-cog'), array('user_management', 'icon-user'), array('workspace_management', 'icon-book'), array('badges_management', 'icon-trophy'), array('registration_to_workspace', 'icon-book'), array('platform_plugins', 'icon-wrench'), array('home_tabs', 'icon-th-large'), array('desktop_tools', 'icon-pencil'), array('platform_logs', 'icon-reorder'), array('platform_analytics', 'icon-bar-chart'), array('roles_management', 'icon-group'));
     $existingTools = $this->objectManager->getRepository('ClarolineCoreBundle:Tool\\AdminTool')->findAll();
     if (count($existingTools) === 0) {
         foreach ($tools as $tool) {
             $entity = new AdminTool();
             $entity->setName($tool[0]);
             $entity->setClass($tool[1]);
             $this->objectManager->persist($entity);
         }
     }
     $this->objectManager->flush();
 }
开发者ID:claroline,项目名称:distribution,代码行数:21,代码来源:Updater021400.php


注:本文中的Claroline\CoreBundle\Persistence\ObjectManager::flush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。