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


PHP EntityRepository::find方法代码示例

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


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

示例1: showEntityNameAction

 /**
  * @param int $id
  *
  * @return Entity
  *
  * @throws \Exception
  */
 public function showEntityNameAction($id)
 {
     if ($entity = $this->entityRepository->find($id)) {
         return $entity->getName();
     }
     throw new \Exception();
 }
开发者ID:carlosV2,项目名称:BDD-Example,代码行数:14,代码来源:ShowEntityNameController.php

示例2: writeItem

 /**
  * {@inheritdoc}
  */
 public function writeItem(array $item)
 {
     $this->counter++;
     $entity = null;
     // If the table was not truncated to begin with, find current entities
     // first
     if (false === $this->truncate) {
         if ($this->index) {
             // If the table has a composite key
             if (!empty($this->compositeKey) && is_array($this->compositeKey)) {
                 $composite = '';
                 foreach ($this->compositeKey as $key => $index) {
                     $composite .= $item[$index];
                 }
                 $value = $composite;
             } else {
                 $value = $item[$this->index];
             }
             $entity = $this->entityRepository->findOneBy(array($this->index => $value));
         } else {
             $entity = $this->entityRepository->find(current($item));
         }
     }
     if (!$entity) {
         $entity = $this->getNewInstance();
     }
     $fieldNames = array_merge($this->entityMetadata->getFieldNames(), $this->entityMetadata->getAssociationNames());
     foreach ($fieldNames as $fieldName) {
         $value = null;
         if (isset($item[$fieldName])) {
             $value = $item[$fieldName];
         } elseif (method_exists($item, 'get' . ucfirst($fieldName))) {
             $value = $item->{'get' . ucfirst($fieldName)};
         }
         if (null === $value) {
             continue;
         }
         if (!$value instanceof \DateTime || $value != $this->entityMetadata->getFieldValue($entity, $fieldName)) {
             $setter = 'set' . ucfirst($fieldName);
             $this->setValue($entity, $value, $setter);
         }
     }
     $this->entityManager->persist($entity);
     if ($this->counter % $this->batchSize == 0) {
         $this->entityManager->flush();
         $this->entityManager->clear($this->entityName);
     }
     return $this;
 }
开发者ID:pclaitte,项目名称:data-import,代码行数:52,代码来源:DoctrineWriter.php

示例3: findOrCreateItem

 /**
  * Finds existing entity or create a new instance
  */
 protected function findOrCreateItem(array $item)
 {
     $entity = null;
     // If the table was not truncated to begin with, find current entity
     // first
     if (false === $this->truncate) {
         if ($this->lookupFields) {
             $lookupConditions = array();
             foreach ($this->lookupFields as $fieldName) {
                 $lookupConditions[$fieldName] = $item[$fieldName];
             }
             $entity = $this->entityRepository->findOneBy($lookupConditions);
         } else {
             $entity = $this->entityRepository->find(current($item));
         }
     }
     if (!$entity) {
         return $this->getNewInstance();
     }
     return $entity;
 }
开发者ID:lmkhang,项目名称:mcntw,代码行数:24,代码来源:DoctrineWriter.php

示例4: find

 /**
  * {@inheritDoc}
  */
 public function find($id)
 {
     return $this->entityRepository->find($id);
 }
开发者ID:weemen,项目名称:hangman_lennard,代码行数:7,代码来源:DoctrineRepository.php

示例5: findCommentById

 /**
  * Find one comment by its ID
  *
  * @return Comment or null
  **/
 public function findCommentById($id)
 {
     return $this->repository->find($id);
 }
开发者ID:helmer,项目名称:FOSCommentBundle,代码行数:9,代码来源:CommentManager.php

示例6: getEvent

 /**
  * Get the CalendarEvent entity.
  * 
  * @param integer $id
  * @return CalendarEventInterface
  */
 public function getEvent($id)
 {
     return $this->repository->find($id);
 }
开发者ID:mogilvie,项目名称:CalendarBundle,代码行数:10,代码来源:CalendarReoccuranceManager.php

示例7: findInvoiceById

 /**
  * {@inheritDoc}
  */
 public function findInvoiceById($id)
 {
     return $this->repository->find($id);
 }
开发者ID:Luupab,项目名称:InvoiceBundle,代码行数:7,代码来源:InvoiceManager.php

示例8: findOrder

 /**
  * {@inheritdoc}
  */
 public function findOrder($id)
 {
     return $this->repository->find($id);
 }
开发者ID:hd-deman,项目名称:Chewbacca,代码行数:7,代码来源:OrderManager.php


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