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


PHP EntityManagerInterface::getRepository方法代码示例

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


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

示例1: getLabel

 /**
  * @param RuleAction $action
  * @return string
  */
 public function getLabel(RuleAction $action)
 {
     $params = $this->getParams($action);
     $repo = $this->entityManager->getRepository('HomefinanceBundle:Category');
     $category = $repo->findOneBy(array('id' => $params['category_id']));
     return $this->translator->trans('rules.actions.set_category.label', array('%category%' => $category->getTitle()), 'rules');
 }
开发者ID:jaapjansma,项目名称:homefinance,代码行数:11,代码来源:SetCategory.php

示例2: __construct

 /**
  * @param EntityManagerInterface $entityManager
  */
 public function __construct(EntityManagerInterface $entityManager)
 {
     $this->entityManager = $entityManager;
     $this->nextPrimaryKeyRepository = $this->entityManager->getRepository('Sinergi\\Sage50\\NextPrimaryKey\\NextPrimaryKeyEntity');
     $this->journalEntryRepository = $this->entityManager->getRepository('Sinergi\\Sage50\\JournalEntry\\JournalEntryEntity');
     $this->locationInventoryRepository = $this->entityManager->getRepository('Sinergi\\Sage50\\LocationInventory\\LocationInventoryEntity');
 }
开发者ID:Linkupdated,项目名称:sage50,代码行数:10,代码来源:SaleOrderBuilder.php

示例3: getRepository

 /**
  * {@inheritdoc}
  */
 public function getRepository($entity = null)
 {
     if ($entity === null) {
         return $this->em->getRepository($this->getEntityName());
     }
     return $this->em->getRepository($entity);
 }
开发者ID:nuxia,项目名称:nuxia-plugin,代码行数:10,代码来源:AbstractEntityManager.php

示例4: down

 /**
  * @param Schema $schema
  */
 public function down(Schema $schema)
 {
     $rep = $this->em->getRepository('AnimeDbCatalogBundle:Genre');
     foreach (array_keys($this->genres) as $en) {
         $this->em->remove($rep->findOneBy(['name' => $en]));
     }
 }
开发者ID:anime-db,项目名称:catalog-bundle,代码行数:10,代码来源:Version20140408113030_AddItemGenres.php

示例5: getMassActions

 /**
  * {@inheritdoc}
  */
 public function getMassActions()
 {
     $archiveAction = new MassAction('Archive', function ($ids) {
         /** @var InvoiceRepository $invoiceRepository */
         $invoiceRepository = $this->entityManager->getRepository('CSBillInvoiceBundle:Invoice');
         /** @var Invoice[] $invoices */
         $invoices = $invoiceRepository->findBy(array('id' => $ids));
         /** @var FlashBag $flashBag */
         $flashBag = $this->session->getBag('flashes');
         $failed = 0;
         foreach ($invoices as $invoice) {
             try {
                 $this->invoiceManager->archive($invoice);
             } catch (InvalidTransitionException $e) {
                 $flashBag->add('warning', $e->getMessage());
                 ++$failed;
             }
         }
         if ($failed !== count($invoices)) {
             $flashBag->add('success', 'invoice.archive.success');
         }
     }, true);
     $archiveAction->setIcon('archive');
     $archiveAction->setClass('warning');
     return array($archiveAction, new DeleteMassAction());
 }
开发者ID:Codixis,项目名称:CSBill,代码行数:29,代码来源:InvoiceRecurringGrid.php

示例6: getItem

 /**
  * @param $productId
  * @return bool|Product
  */
 public function getItem($productId)
 {
     if (isset($this->cart[$productId])) {
         return $this->entityManager->getRepository('ProductBundle:Product')->find($productId);
     }
     return false;
 }
开发者ID:ernestre,项目名称:illuminati,代码行数:11,代码来源:CartProvider.php

示例7: getRepository

 /**
  * Get repository.
  *
  * @return TaskEntityRepository
  */
 public function getRepository()
 {
     if (null === $this->repository) {
         $this->repository = $this->entityManager->getRepository(TaskEntity::class);
     }
     return $this->repository;
 }
开发者ID:gravitymedia,项目名称:commander,代码行数:12,代码来源:TaskManager.php

示例8: getRepository

 /**
  * @return \Doctrine\Common\Persistence\ObjectRepository
  */
 private function getRepository()
 {
     if ($this->repository === null) {
         $this->repository = $this->entityManager->getRepository('ItBlasterSingleConfigBundle:Config');
     }
     return $this->repository;
 }
开发者ID:it-blaster,项目名称:single-config-bundle,代码行数:10,代码来源:ConfigService.php

示例9: getOrderInfo

 /**
  * @return array
  */
 private function getOrderInfo()
 {
     $order = $this->entityManager->getRepository('AppBundle:TicketsOrder')->findOneBy(array('ref' => $this->orderRef));
     $orderId = $order->getId();
     $isValidate = $order->isValidate();
     return array($order, $orderId, $isValidate);
 }
开发者ID:famfij,项目名称:TP-BilletsDuLouvre,代码行数:10,代码来源:PaymentControllerTest.php

示例10: testImportExport

 /**
  * @medium
  */
 public function testImportExport()
 {
     $sourceStorage = new LocalFileStorage(new \SplFileInfo(__DIR__ . '/../../../metadata/testfiles/100.csv'), new CsvFormat());
     $targetStorage = new DoctrineStorage(self::$em, 'TestEntities\\Address');
     $this->assertEquals(new StorageInfo(['name' => 'SELECT o FROM TestEntities\\Address o', 'count' => 0, 'type' => 'DQL Query']), $targetStorage->info());
     $importer = Importer::build($targetStorage);
     $importConfiguration = new ImportConfiguration();
     $importRun = $importConfiguration->toRun();
     $import = Import::build($importer, $sourceStorage, $importRun);
     $eventDispatcher = new EventDispatcher();
     $importRunner = new ImportRunner(new DefaultWorkflowFactory($eventDispatcher));
     $importRunner->run($import);
     $entities = self::$em->getRepository('TestEntities\\Address')->findAll();
     //import worked
     $this->assertEquals(100, count($entities));
     $exportFile = '/tmp/doctrine_test.csv';
     @unlink($exportFile);
     $sourceStorage = new DoctrineStorage(self::$em, null, self::$em->createQuery("SELECT A FROM TestEntities\\Address A WHERE A.zip LIKE '2%'"));
     $this->assertEquals(new StorageInfo(['name' => "SELECT A FROM TestEntities\\Address A WHERE A.zip LIKE '2%'", 'count' => 10, 'type' => 'DQL Query']), $sourceStorage->info());
     $targetStorage = new LocalFileStorage(new \SplFileInfo($exportFile), new CsvFormat());
     $importer = Importer::build($targetStorage);
     $importConfiguration = new ImportConfiguration();
     $importRun = $importConfiguration->toRun();
     $import = Import::build($importer, $sourceStorage, $importRun);
     $eventDispatcher = new EventDispatcher();
     $importRunner = new ImportRunner(new DefaultWorkflowFactory($eventDispatcher));
     $importRunner->run($import);
     $this->assertFileExists($exportFile);
     $this->assertEquals(11, count(file($exportFile)));
     //+header
     $this->assertEquals(10, $import->getRun()->toArray()['statistics']['processed']);
 }
开发者ID:mathielen,项目名称:import-engine,代码行数:35,代码来源:DoctrineTest.php

示例11: notify

 public function notify(UrlEvent $event)
 {
     if (!$this->isEnabled() || !$event->getUrl() || $event->getType() !== Shortener::NOTIFY_TYPE_REDIRECT) {
         return false;
     }
     $additional = $event->getAdditional();
     $ip = !empty($additional['ip']) ? $additional['ip'] : null;
     if (!$ip) {
         return false;
     }
     $urlRepository = $this->em->getRepository('Rz\\Bundle\\UrlShortenerBundle\\Entity\\Url');
     $urlStatRepository = $this->em->getRepository('Rz\\Bundle\\UrlShortenerBundle\\Entity\\UrlStat');
     /** @var Url $url */
     $url = $urlRepository->find($event->getUrl()->getId());
     $url->incrementRedirectCount();
     $url->setLastRedirectOn(new \DateTime());
     $urlStat = $urlStatRepository->findOneBy(['Url' => $url, 'ip' => $ip]);
     if (!$urlStat) {
         $url->incrementUniqueRedirectCount();
         $urlStat = new UrlStat();
         $urlStat->setUrl($url);
         $urlStat->setCreated(new \DateTime());
         $urlStat->setIp($ip);
         if (!empty($additional['user-agent'])) {
             $urlStat->setUserAgent($additional['user-agent']);
         }
         $this->em->persist($urlStat);
     }
     $this->em->persist($url);
     $this->em->flush();
     return true;
 }
开发者ID:RuslanZavacky,项目名称:url-shortener-api,代码行数:32,代码来源:StatsListener.php

示例12: __construct

 /**
  * @param EntityManagerInterface $em
  */
 public function __construct(EntityManagerInterface $em)
 {
     $this->em = $em;
     $this->contentRepository = $em->getRepository(ContentItem::class);
     $this->taxonomyRepository = $em->getRepository(Taxonomy::class);
     $this->termRepository = $em->getRepository(Term::class);
 }
开发者ID:jtallant,项目名称:skimpy-engine,代码行数:10,代码来源:Skimpy.php

示例13: __construct

 /**
  * UserFiledsetFilter constructor.
  * @param EntityManagerInterface $em
  * @param null $config
  */
 public function __construct(EntityManagerInterface $em, $config = null)
 {
     $this->add(['name' => 'id', 'required' => true, 'filters' => [['name' => 'Int']]]);
     $this->add(['name' => 'username', 'required' => true, 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']], 'validators' => [['name' => 'StringLength', 'options' => ['encoding' => 'UTF-8', 'min' => 5, 'max' => 100]], ['name' => 'DoctrineModule\\Validator\\UniqueObject', 'options' => ['use_context' => true, 'object_manager' => $em, 'object_repository' => $em->getRepository($config['identityClass']), 'fields' => $config['identityProperty'], 'messages' => [UniqueObject::ERROR_OBJECT_NOT_UNIQUE => sprintf(_('The username %s already exists'), '\'%value%\'')]]]]]);
     $this->add(['name' => 'email', 'required' => true, 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']], 'validators' => [['name' => 'EmailAddress', 'options' => ['message' => _('Invalid email address')]], ['name' => 'DoctrineModule\\Validator\\UniqueObject', 'options' => ['use_context' => true, 'object_manager' => $em, 'object_repository' => $em->getRepository($config['identityClass']), 'fields' => $config['identityEmail'], 'messages' => [UniqueObject::ERROR_OBJECT_NOT_UNIQUE => sprintf(_('The email %s already exists'), '\'%value%\'')]]]]]);
     $this->add(['name' => 'password', 'required' => true, 'filters' => [['name' => 'StringTrim'], ['name' => 'StringTrim']], 'validators' => [['name' => 'StringLength', 'options' => ['encoding' => 'UTF-8', 'min' => 6, 'max' => 128]]]]);
 }
开发者ID:zetta-code,项目名称:tss-authentication,代码行数:12,代码来源:UserFiledsetFilter.php

示例14: fetchFacebookEvents

 public function fetchFacebookEvents()
 {
     $events = $this->em->getRepository('NFQKVKScraperBundle:EventData')->getAllEventsWithFacebookId();
     foreach ($events as $eventData) {
         $this->populateFacebookEvent($eventData);
     }
 }
开发者ID:nfq-akademija-2015-ruduo,项目名称:Kas_vyksta_Kaune,代码行数:7,代码来源:FacebookEventManager.php

示例15: updateEntity

 /**
  * @param $configKey
  * @param $objectId
  * @param $value
  * @param null|string $dataField
  * @throws ContentEditableException
  */
 public function updateEntity($configKey, $objectId, $value, $dataField = null)
 {
     if (!array_key_exists($configKey, $this->configuration['configurations'])) {
         throw new ContentEditableException('Missing configuration "' . $configKey . '"');
     }
     $config = $this->configuration['configurations'][$configKey];
     if ($dataField == null) {
         if (!array_key_exists('data_field', $config)) {
             throw new ContentEditableException('Missing data_field');
         }
         $dataField = $config['data_field'];
     }
     $idField = 'id';
     if (array_key_exists('id_field', $config)) {
         $idField = $config['id_field'];
     }
     $repository = $this->entityManager->getRepository($config['repository_class']);
     $entity = $repository->findOneBy([$idField => $objectId]);
     $setter = 'set' . ucfirst($dataField);
     if (!method_exists($entity, $setter)) {
         throw new ContentEditableException('No setter "' . $setter . '" found for "' . get_class($entity) . '"');
     }
     $entity->{$setter}(trim($value));
     $this->entityManager->persist($entity);
     $this->entityManager->flush();
 }
开发者ID:janoist1,项目名称:ContentEditableBundle,代码行数:33,代码来源:ContentEditableService.php


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