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


PHP EntityRepository::getEntityManager方法代码示例

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


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

示例1: em

 public function em()
 {
     return parent::getEntityManager();
 }
开发者ID:raivieira,项目名称:base-api-php,代码行数:4,代码来源:BaseRepository.php

示例2: populateEntity

 /**
  * Populate the EntityRepository $repo with $count entities.
  *
  * @see \Population\Populator::populate
  *
  * @access public
  * @param EntityRepository $repo
  * @param int $count
  * @param array $options
  * @param callable $callback Function which populates the data for each instance. It is passed a single argument,
  *     the entity to be populated. If $callback returns false, the entity will not be persisted.
  * @param array $options (default: array())
  *     perFlush:        Limit the number of insertions performed in a single flush (default: 100)
  *     clearAfterFlush: Clear the EntityManager after each flush (default:true)
  *     factory:         Optionally, specify a factory callback for populated objects
  *     constructorArgs: An array of args, passed directly to the document's constructor (default: null)
  * @return void
  */
 public function populateEntity(EntityRepository $repo, $count, $callback, array $options = array())
 {
     $em = $repo->getEntityManager();
     if (isset($options['factory'])) {
         $factory = $options['factory'];
     } else {
         $reflClass = $repo->getClassMetadata()->reflClass;
         $factory = array($reflClass, 'newInstanceArgs');
     }
     $this->populateObject($em, $factory, $count, $callback, $options);
 }
开发者ID:bobthecow,项目名称:population,代码行数:29,代码来源:Populator.php

示例3: addLast

 function addLast($entity, $persist = true)
 {
     if (!$entity instanceof $this->className) {
         throw new InvalidArgumentException('The item must be an instace of ' . $this->className);
     }
     $parentEntityId = $this->getParentIdentifierValue($entity);
     if (!array_key_exists($parentEntityId, $this->cachedMaxOrder)) {
         $this->cachedMaxOrder[$parentEntityId] = null;
     }
     if ($this->cachedMaxOrder[$parentEntityId] === null) {
         $qb = $this->getEntityManager()->createQueryBuilder()->select('MAX(o.' . $this->orderField . ')')->from($this->className, 'o');
         if ($this->useParent()) {
             $qb = $this->addParentQueryBuilderCondition($qb, $parentEntityId);
         }
         $this->cachedMaxOrder[$parentEntityId] = $qb->getQuery()->getSingleScalarResult();
         if ($this->cachedMaxOrder[$parentEntityId] == null) {
             $this->cachedMaxOrder[$parentEntityId] = 1;
         }
     }
     $this->cachedMaxOrder[$parentEntityId]++;
     $entity->_setPosition($this->cachedMaxOrder[$parentEntityId]);
     if ($persist) {
         parent::getEntityManager()->persist($entity);
     }
 }
开发者ID:brunoreis,项目名称:DoctrineLearning,代码行数:25,代码来源:OrderedRepository.class.php


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