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


PHP ObjectManager::persist方法代码示例

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


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

示例1: load

 /**
  * Loads the core Home Tabs.
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $translator = $this->container->get('translator');
     $infoName = $translator->trans('informations', array(), 'platform');
     $desktopHomeTab = new HomeTab();
     $desktopHomeTab->setType('admin_desktop');
     $desktopHomeTab->setName($infoName);
     $manager->persist($desktopHomeTab);
     $desktopHomeTabConfig = new HomeTabConfig();
     $desktopHomeTabConfig->setHomeTab($desktopHomeTab);
     $desktopHomeTabConfig->setType('admin_desktop');
     $desktopHomeTabConfig->setVisible(true);
     $desktopHomeTabConfig->setLocked(false);
     $desktopHomeTabConfig->setTabOrder(1);
     $manager->persist($desktopHomeTabConfig);
     $workspaceHomeTab = new HomeTab();
     $workspaceHomeTab->setType('admin_workspace');
     $workspaceHomeTab->setName($infoName);
     $manager->persist($workspaceHomeTab);
     $workspaceHomeTabConfig = new HomeTabConfig();
     $workspaceHomeTabConfig->setHomeTab($workspaceHomeTab);
     $workspaceHomeTabConfig->setType('admin_workspace');
     $workspaceHomeTabConfig->setVisible(true);
     $workspaceHomeTabConfig->setLocked(false);
     $workspaceHomeTabConfig->setTabOrder(1);
     $manager->persist($workspaceHomeTabConfig);
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:32,代码来源:LoadHomeTabData.php

示例2: 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

示例3: role

 /**
  * @param string $name
  *
  * @return Role
  */
 public function role($name)
 {
     $role = new Role();
     $role->setName($name);
     $role->setTranslationKey($name);
     $this->om->persist($role);
     return $role;
 }
开发者ID:claroline,项目名称:distribution,代码行数:13,代码来源:Persister.php

示例4: 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

示例5: 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

示例6: subscribe

 /**
  * Subscribes a Use to an Exercise.
  *
  * @param Exercise $exercise
  * @param User     $user
  * @param bool     $flush
  *
  * @return SubscriptionManager
  */
 public function subscribe(Exercise $exercise, User $user, $flush = false)
 {
     $subscription = new Subscription();
     $subscription->setUser($user);
     $subscription->setExercise($exercise);
     $subscription->setAdmin(true);
     $subscription->setCreator(true);
     $this->om->persist($subscription);
     if ($flush) {
         $this->om->flush();
     }
     return $this;
 }
开发者ID:claroline,项目名称:distribution,代码行数:22,代码来源:SubscriptionManager.php

示例7: updateIcons

 public function updateIcons()
 {
     $this->log('updating icons...');
     $mimetypes = array('application/illustrator', 'application/ai');
     foreach ($mimetypes as $mimetype) {
         $icon = new ResourceIcon();
         $icon->setRelativeUrl('bundles/clarolinecore/images/resources/icons/res_vector.png');
         $icon->setMimeType($mimetype);
         $icon->setShortcut(false);
         $this->om->persist($icon);
         $this->container->get('claroline.manager.icon_manager')->createShortcutIcon($icon);
     }
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:13,代码来源:Updater021401.php

示例8: 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

示例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: 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

示例11: 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

示例12: setHomepage

 public function setHomepage(Website $website, WebsitePage $page)
 {
     $website->setHomePage($page);
     $page->setIsHomepage(true);
     $this->objectManager->persist($page);
     $this->objectManager->persist($website);
     $this->objectManager->flush();
 }
开发者ID:claroline,项目名称:distribution,代码行数:8,代码来源:WebsitePageManager.php

示例13: 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

示例14: load

 public function load(ObjectManager $manager)
 {
     $themes = $this->container->get('claroline.manager.theme_manager')->listStockThemeNames();
     foreach ($themes as $name) {
         $theme = new Theme();
         $theme->setName($name);
         $manager->persist($theme);
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:9,代码来源:LoadThemeData.php

示例15: hint

 public function hint(Question $question, $text, $penalty = 1)
 {
     $hint = new Hint();
     $hint->setValue($text);
     $hint->setPenalty($penalty);
     $hint->setQuestion($question);
     $this->om->persist($hint);
     return $hint;
 }
开发者ID:claroline,项目名称:distribution,代码行数:9,代码来源:Persister.php


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