當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。