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


PHP EntityRepository类代码示例

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


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

示例1: loadSuggestions

 /**
  * Load Beer's Suggestions based on the color
  * @param EntityRepository $em
  * @param int $id
  * @param int $color
  * @return Beers
  */
 private function loadSuggestions($em, $id, $color)
 {
     return $em->getRepository('BBGCatalogBundle:Beer')->getSuggestions($id, $color);
 }
开发者ID:vfauvarque,项目名称:BBG,代码行数:11,代码来源:BeerController.php

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

示例3: findVotesByComment

 /**
  * Finds all votes belonging to a comment.
  *
  * @param  \FOS\CommentBundle\Model\VotableCommentInterface $comment
  * @return array|null
  */
 public function findVotesByComment(VotableCommentInterface $comment)
 {
     $qb = $this->repository->createQueryBuilder('v');
     $qb->join('v.comment', 'c');
     $qb->andWhere('c.id = :commentId');
     $qb->setParameter('commentId', $comment->getId());
     $votes = $qb->getQuery()->execute();
     return $votes;
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:15,代码来源:VoteManager.php

示例4: findInvoiceItemsByInvoiceId

 /**
  * {@inheritDoc}
  */
 public function findInvoiceItemsByInvoiceId($invoiceId)
 {
     $qb = $this->repository->createQueryBuilder('a');
     $qb->join('a.invoice', 't')->where('t.id = :invoiceId')->setParameter('invoiceId', $invoiceId);
     $invoiceiItems = $qb->getQuery()->execute();
     if (!$invoiceiItems) {
         return array();
     }
     return $invoiceiItems;
 }
开发者ID:Luupab,项目名称:InvoiceBundle,代码行数:13,代码来源:InvoiceItemManager.php

示例5: setRepositoryLocale

 /**
  * Sets the repository request default locale
  *
  * @param ContainerInterface|null $container
  * 
  * @throws \InvalidArgumentException if repository is not an instance of TranslatableRepository
  */
 public function setRepositoryLocale($container)
 {
     if (null !== $container) {
         if (!$this->repository instanceof TranslatableRepository) {
             throw new \InvalidArgumentException('A TranslatableManager needs to be linked with a TranslatableRepository to sets default locale.');
         }
         if ($container->isScopeActive('request')) {
             $locale = $container->get('request')->getLocale();
             $this->repository->setDefaultLocale($locale);
         }
     }
 }
开发者ID:ChristWood,项目名称:videoCollection,代码行数:19,代码来源:TranslatableManager.php

示例6: processRepositoryLocale

 public function processRepositoryLocale()
 {
     if (null !== $this->container) {
         if (!$this->repository instanceof \SKCMS\CoreBundle\Repository\TranslatableRepository) {
             dump($this->repository);
             die;
             throw new \InvalidArgumentException('A TranslatableManager needs to be linked with a TranslatableRepository to sets default locale.');
         }
         if ($this->container->isScopeActive('request')) {
             //                die('locale'. $this->container->get('request')->getLocale());
             $locale = $this->container->get('request')->getLocale();
             $this->repository->setDefaultLocale($locale);
         }
     }
 }
开发者ID:kokmok,项目名称:SKCMS-Core,代码行数:15,代码来源:TranslatableManager.php

示例7: load

 /**
  * Lädt ein Bild aus der Datenbank
  * 
  * @params $input
  * 
  * @param int    $input die ID des Entities
  * @param string $input der gespeicherte sourcePath des Entities (muss / oder \ enthalten)
  * @param string $input der sha1 hash der Bildinformationen des OriginalBildes
  * @return Psc\Image\Image
  * @throws Psc\Image\NotFoundException
  */
 public function load($input)
 {
     try {
         if (is_numeric($input)) {
             $image = $this->imageRep->hydrate((int) $input);
         } elseif (is_string($input) && (mb_strpos($input, '/') !== FALSE || mb_strpos($input, '\\') !== FALSE)) {
             $image = $this->imageRep->hydrateBy(array('sourcePath' => (string) $input));
         } elseif (is_string($input)) {
             // hash
             $image = $this->imageRep->hydrateBy(array('hash' => (string) $input));
         } elseif ($input instanceof Image) {
             $image = $input;
         } elseif ($input instanceof ImagineImage) {
             throw new \Psc\Exception('von einer ImagineResource kann kein Bild geladen werden');
         } else {
             throw new \Psc\Exception('Input kann nicht analyisiert werden: ' . Code::varInfo($input));
         }
         $this->attach($image);
         return $image;
     } catch (\Psc\Doctrine\EntityNotFoundException $e) {
         $e = new NotFoundException('Image nicht gefunden: ' . Code::varInfo($input), 1, $e);
         $e->searchCriteria = $input;
         throw $e;
     }
 }
开发者ID:pscheit,项目名称:psc-cms-image,代码行数:36,代码来源:Manager.php

示例8: resolveTable

 private function resolveTable($arg)
 {
     if ($arg == '#') {
         $path = array('base');
     } else {
         $path = explode('.', trim($arg, '.#'));
         array_unshift($path, "base");
     }
     foreach ($path as $index => $item) {
         if ($item == 'base') {
             $metadata = $this->repository->getMetadata();
             $table = $metadata->getTable();
             $tableAs = 'base';
             if (!$this->getTableAs($tableAs)) {
                 $this->setTableAs($tableAs, $table, $metadata);
             }
         } else {
             //	tabulka
             $association = $metadata->getAssociation($item);
             $associationClassName = $association->getReferenceClass();
             $associationMetadata = $this->repository->getEntityManager()->getRepository($associationClassName)->getMetadata();
             $parentTable = $table;
             $parentTableAs = $tableAs;
             $table = $associationMetadata->getTable();
             $tableAs = $tableAs . self::ALIAS_SEPARATOR . $item;
             //	Nevytvaret novy stejny join. Jen, pokud je jina vazba, nebo jiny nazev.
             if (!$this->getTableAs($tableAs)) {
                 $this->setTableAs($tableAs, $table, $metadata, $parentTableAs, $association);
             }
         }
     }
     return $tableAs;
 }
开发者ID:matak,项目名称:dbrecord,代码行数:33,代码来源:Query.php

示例9: pk

 /**
  * 
  * @param type $pk
  * @return item|null
  */
 public function pk($pk)
 {
     $pkName = $this->repository->getMetadata()->getPrimaryColumn();
     foreach ($this as $item) {
         if ($item->{$pkName} == $pk) {
             return $item;
         }
     }
     return NULL;
 }
开发者ID:matak,项目名称:dbrecord,代码行数:15,代码来源:EntityCollection.php

示例10: filterProduct

 /**
  * Filter a product (return null if the product got exported after his last edit)
  * @param AbstractProduct $product
  * @param JobInstance     $jobInstance
  *
  * @return AbstractProduct|null
  */
 public function filterProduct(AbstractProduct $product, JobInstance $jobInstance)
 {
     $productExport = $this->productExportRepository->findProductExportAfterEdit($product->getOriginalProduct(), $jobInstance, $product->getUpdated());
     if (0 === count($productExport)) {
         if ($this->productValueDelta) {
             $product = $this->filterProductValues($product);
         }
     } else {
         $product = null;
     }
     return $product;
 }
开发者ID:calin-marian,项目名称:DrupalCommerceConnectorBundle,代码行数:19,代码来源:ProductExportManager.php

示例11: searchLocalAuthor

 /**
  * search local authors based of the parameters and filters given
  * @param array $params  []
  * @param array $filters []
  *
  * @return array
  */
 public function searchLocalAuthor($params, $filters)
 {
     $city = isset($params['city']) ? $params['city'] : 0;
     $country = isset($params['country']) ? $params['country'] : 0;
     $name = isset($filters['name']) ? $filters['name'] : '';
     $page = isset($filters['page']) ? $filters['page'] : 1;
     $limit = isset($filters['limit']) ? $filters['limit'] : 0;
     $search = array();
     //search all
     if ($country == 0 && $city == 0) {
         $data = $this->repository->findAllWithFilters($limit, ($page - 1) * $limit, $name);
         $totalCount = count($data);
         $search = array('count' => $totalCount, 'result' => $data);
     } else {
         if ($country > 0 && $city == 0) {
             //search by country
             $this->setRepository('BugglMainBundle:Location');
             $data = $this->repository->findAllByCountry($country, $limit, ($page - 1) * $limit, $name);
             $totalCount = count($data);
             $authors = array();
             foreach ($data as $each) {
                 $authors[] = $each->getLocalAuthor();
             }
             $search = array('count' => $totalCount, 'result' => $authors);
         } else {
             if ($country > 0 && $city > 0) {
                 //search by  city
                 $this->setRepository('BugglMainBundle:Location');
                 $data = $this->repository->findAllByCity($city, $limit, ($page - 1) * $limit, $name);
                 $totalCount = count($data);
                 $authors = array();
                 foreach ($data as $each) {
                     $authors[] = $each->getLocalAuthor();
                 }
                 $search = array('count' => $totalCount, 'result' => $authors);
             }
         }
     }
     return $search;
 }
开发者ID:thebuggl-org,项目名称:tests-buggl,代码行数:47,代码来源:BugglSearchLocalAuthor.php

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

示例13: isOrgRestrictionMet

 /**
  * @param array $organizationCodes
  *
  * @return bool
  */
 protected function isOrgRestrictionMet(array $organizationCodes)
 {
     if (false === $this->authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         return false;
     }
     if (true === $this->authorizationChecker->isGranted('ROLE_ROOT')) {
         return true;
     }
     if (null === $this->orgRepo) {
         return false;
     }
     foreach ($organizationCodes as $code) {
         $organization = $this->orgRepo->findOneByCode($code);
         if (true === $this->authorizationChecker->isGranted('IS_ORGANIZATION_MANAGER', $organization)) {
             return true;
         }
     }
     return false;
 }
开发者ID:scr-be,项目名称:teavee-scribble-down-bundle,代码行数:24,代码来源:SwimBlockRestrictionsHandler.php

示例14: isGranted

 /**
  * Is granted
  *
  * @param  string  $slug
  *
  * @return boolean
  */
 private function isGranted($slug)
 {
     $roles = $this->user->getRoles();
     /** @var Role $role */
     if (in_array('ROLE_ADMIN', $roles)) {
         return true;
     }
     $granted = false;
     $roleMenu = $this->repository->findOneBySlug($slug);
     if ($roleMenu instanceof RoleMenu) {
         if (count($roleMenu->getRoles())) {
             $granted = false;
             foreach ($roleMenu->getArrayRoles() as $role) {
                 if (in_array($role, $roles)) {
                     $granted = true;
                 }
             }
         }
     }
     return $granted;
 }
开发者ID:7rin0,项目名称:BigfootCoreBundle,代码行数:28,代码来源:MenuManager.php

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


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