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


PHP ObjectManager::detach方法代码示例

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


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

示例1: setPublicUrlOnUsers

 protected function setPublicUrlOnUsers()
 {
     $this->log('Updating public url for users...');
     /** @var \Claroline\CoreBundle\Repository\UserRepository $userRepository */
     $userRepository = $this->objectManager->getRepository('ClarolineCoreBundle:User');
     $this->log('User to update - ' . date('Y/m/d H:i:s'));
     $this->log('It may take a while to process, go grab a coffee.');
     /** @var \Claroline\CoreBundle\Manager\UserManager $userManager */
     $userManager = $this->container->get('claroline.manager.user_manager');
     $nbUsers = 0;
     /** @var \Claroline\CoreBundle\Entity\User $user */
     $user = $userRepository->findOneByPublicUrl(null);
     while (null !== $user) {
         $publicUrl = $userManager->generatePublicUrl($user);
         $user->setPublicUrl($publicUrl);
         $this->objectManager->persist($user);
         $this->objectManager->flush();
         $nbUsers++;
         if (100 === $nbUsers) {
             $this->log('    ' . $nbUsers . ' updated users - ' . date('Y/m/d H:i:s'));
             $nbUsers = 0;
         }
         $personalWorkspace = $user->getPersonalWorkspace();
         if (null !== $personalWorkspace) {
             $this->objectManager->detach($personalWorkspace);
         }
         $this->objectManager->detach($user);
         $user = $userRepository->findOneByPublicUrl(null);
     }
     $this->log('Public url for users updated.');
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:31,代码来源:Updater021200.php

示例2: reorder

 /**
  * @param ResourceNode $node
  * @param bool         $detach
  */
 public function reorder(ResourceNode $node, $detach = false)
 {
     /** @var \Claroline\CoreBundle\Repository\ResourceNodeRepository $resourceNodeRepository */
     $resourceNodeRepository = $this->om->getRepository('ClarolineCoreBundle:Resource\\ResourceNode');
     $children = $resourceNodeRepository->getChildren($node, true, 'index');
     $index = 1;
     foreach ($children as $child) {
         $child->setIndex($index);
         $index++;
         $this->om->persist($child);
     }
     $this->om->flush();
     if ($detach) {
         foreach ($children as $child) {
             $this->om->detach($child);
         }
     }
 }
开发者ID:ChMat,项目名称:CoreBundle,代码行数:22,代码来源:ResourceManager.php


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