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


PHP EntityManager::getRepository方法代码示例

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


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

示例1: execute

 /**
  * The event handler function for callback function.
  * Convert audion file
  * @param AMQPMessage $msg
  */
 public function execute(AMQPMessage $msg)
 {
     $session = (int) unserialize($msg->body)['session'];
     $job = $this->container->getRepository('masterofcodeBundle:Job')->find($session);
     if (!$job) {
         throw new NotFoundHttpException("System error: cannot use given session id");
     }
     $this->setStatus($job, 1);
     try {
         $format = new Flac();
         $format->setAudioChannels(2)->setAudioKiloBitrate(128);
         $audio = FFMpeg::create()->open($job->getPath());
         $audio->save($format, $job->getDownloadPath());
     } catch (Exception $e) {
         $this->setStatus($job, 3);
         throw new NotFoundHttpException("System error: cannot convert file.");
     }
     $this->setStatus($job, 2);
     echo 'File ' . $job->getPath() . ' has been converted! Session #' . $job->getId() . "\n";
 }
开发者ID:stanislavVysotskyi,项目名称:masterOfCode,代码行数:25,代码来源:ConvertCommand.php

示例2: savePdf

 public function savePdf()
 {
     $pnr = $this->em->getRepository('AppCoreBundle:Pnr')->find($this->id);
     if (!$pnr) {
         return \Exception('PNR not found');
     }
     //Trick to prevent cache size exceeded
     //set_time_limit(0);
     while (ob_get_level()) {
         ob_end_clean();
     }
     ob_implicit_flush(true);
     /*
      * Construct PDF with Mpdf service
      * Layout based on HTML twig template
      */
     $service = $this->tfox;
     $pdf = $service->getMpdf(array('', 'A4', 8, 'Helvetica', 10, 10, 15, 15, 9, 9, 'L'));
     $pdf->AliasNbPages('{NBPAGES}');
     $pdf->setTitle('billet-' . date('d-m-Y-H-i', time()) . '.pdf');
     $pdf->SetHeader('Billet');
     $pdf->SetFooter('{DATE j/m/Y}|{PAGENO}/{NBPAGES}');
     $html = $this->templating->renderResponse('AppCoreBundle:Pnr:billetpdf.pdf.twig', array('pnr' => $pnr));
     $pdf->WriteHTML($html);
     //$url = 'billet-'.$pnr->getNumero().'.pdf';
     //$pdf->Output($url, 'F');
     $pdf->Output();
     /*$this->get('session')->getFlashBag()->add(
     		 'success',
     				'Le billet a bien été enregistré !'
     		);*/
     //return $this->redirect($this->generateUrl('pnr_emit', array('id' => $id)));
     //return $url;
 }
开发者ID:Bobarisoa,项目名称:noucoz-release,代码行数:34,代码来源:Billet.php

示例3: migrateData

 /**
  * Migrate data to plugin database from core table
  *
  * @param EntityManager   $em
  * @param OutputInterface $output
  *
  * @return void
  */
 public function migrateData($em, $output)
 {
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('Newscoop\\CommunityTickerBundle\\Entity\\CommunityTickerEvent', 'e');
     $rsm->addFieldResult('e', 'id', 'id');
     $rsm->addFieldResult('e', 'event', 'event');
     $rsm->addFieldResult('e', 'params', 'params');
     $rsm->addFieldResult('e', 'created', 'created');
     $rsm->addJoinedEntityResult('Newscoop\\Entity\\User', 'u', 'e', 'user');
     $rsm->addFieldResult('u', 'Id', 'id');
     $query = $em->createNativeQuery('SELECT e.id, e.event, e.params, e.created, u.Id FROM community_ticker_event e ' . 'LEFT JOIN liveuser_users u ON u.id = e.user_id', $rsm);
     $events = $query->getArrayResult();
     foreach ($events as $key => $event) {
         $user = $em->getRepository('Newscoop\\Entity\\User')->findOneBy(array('id' => $event['user']['id']));
         $existingEvent = $em->getRepository('Newscoop\\CommunityTickerBundle\\Entity\\CommunityTickerEvent')->findOneBy(array('created' => $event['created'], 'params' => $event['params']));
         if (!$existingEvent) {
             $newEvent = new CommunityTickerEvent();
             $newEvent->setEvent($event['event']);
             $newEvent->setParams($event['params'] != '[]' ? json_decode($event['params'], true) : array());
             $newEvent->setCreated($event['created']);
             $newEvent->setIsActive(true);
             if ($user) {
                 $newEvent->setUser($user);
             }
             $em->persist($newEvent);
         }
     }
     $em->flush();
     $output->writeln('<info>Data migrated to plugin table!</info>');
     $output->writeln('<info>Removing old table...</info>');
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:39,代码来源:MigrateTablesCommand.php

示例4: testRemoveStock

 public function testRemoveStock()
 {
     $productBefore = $this->_em->getRepository('DreamStoreSellerBundle:Product')->findOneById(1);
     $stockBefor = $productBefore->getStock();
     $table = ['operation' => 'remove', 'stock' => 5];
     $home = new HomeController();
     $productAfter = $home->addNewStock($productBefore, $table);
     $this->assertEquals($stockBefor - 5, $productAfter->getStock());
 }
开发者ID:bamper,项目名称:DreamStore,代码行数:9,代码来源:HomeControllerTest.php

示例5: assertDatabaseEntries

 /**
  * Counts the number of entries in each tables.
  *
  * @param EntityManager $em
  * @param int $expected
  */
 protected function assertDatabaseEntries($em, $expected)
 {
     $number = $em->getRepository(self::ENTITY_TRANS_UNIT_CLASS)->createQueryBuilder('tu')->select('COUNT(tu.id)')->getQuery()->getSingleScalarResult();
     $this->assertEquals($expected, $number);
     $number = $em->getRepository(self::ENTITY_TRANSLATION_CLASS)->createQueryBuilder('t')->select('COUNT(t.id)')->getQuery()->getSingleScalarResult();
     $this->assertEquals($expected * 2, $number);
     $number = $em->getRepository(self::ENTITY_FILE_CLASS)->createQueryBuilder('f')->select('COUNT(f.id)')->getQuery()->getSingleScalarResult();
     $this->assertEquals($expected, $number);
 }
开发者ID:cwd,项目名称:LexikTranslationBundle,代码行数:15,代码来源:FileImporterTest.php

示例6: getRoleChoices

 protected function getRoleChoices()
 {
     $roots = $this->em->getRepository('FpUserBundle:Role')->findAll();
     $choices = array();
     foreach ($roots as $role) {
         $choices[$role->getId()] = $role;
     }
     return $choices;
 }
开发者ID:sourcevx,项目名称:Test,代码行数:9,代码来源:UserType.php

示例7: load

 /**
  * {@inheritDoc}
  */
 public function load($id = 0, $version = 1)
 {
     $this->subject = $this->em->getRepository('OpiferContentBundle:Template')->find($id);
     $this->version = $version;
     if (!$this->subject) {
         throw $this->createNotFoundException('No template found for id ' . $id);
     }
     return $this;
 }
开发者ID:Opifer,项目名称:Cms,代码行数:12,代码来源:TemplateSuite.php

示例8: getEm

 /**
  * @param null $entity
  * @return EntityManager|array|object
  */
 public function getEm($entity = null)
 {
     if ($this->em === null) {
         $this->em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     }
     if ($entity !== null) {
         return $this->em->getRepository($entity);
     }
     return $this->em;
 }
开发者ID:aymone,项目名称:zf2-ecommerce,代码行数:14,代码来源:AbstractController.php

示例9: showAction

 /**
  * @var string slug
  * @throws NotFoundHttpException
  *
  * @Route("/author/{slug}")
  * @Template()
  * @return array
  */
 public function showAction($slug)
 {
     $author = $this->em->getRepository('ModelBundle:Author')->findOneBy(array('slug' => $slug));
     if ($author == null) {
         throw $this->createNotFoundException('Author Not Found');
     } else {
         $posts = $this->em->getRepository('ModelBundle:Post')->findBy(array('author' => $author));
     }
     return array('author' => $author, 'posts' => $posts);
 }
开发者ID:dinushjaykody,项目名称:symfony_blog,代码行数:18,代码来源:AuthorController.php

示例10: testHistorical

 public function testHistorical()
 {
     $product = $this->_em->getRepository('DreamStoreSellerBundle:Product')->findOneById(1);
     $quantity = 50;
     $userName = 'toto';
     $token = 'z49er8c4z9ec';
     $status = 'en cours';
     $payment = new PaymentController();
     $historical = $payment->historical($product, $quantity, $userName, $token, $status);
     $this->assertInstanceOf('DreamStore\\CustomerBundle\\Entity\\Historical', $historical);
 }
开发者ID:bamper,项目名称:DreamStore,代码行数:11,代码来源:PaymentControllerTest.php

示例11: findUserByGoogleSignInData

 /**
  * {@inheritDoc}
  */
 public function findUserByGoogleSignInData($email, $googleId)
 {
     //Check if already logged in before via Google auth
     $user = $this->em->getRepository($this->userClass)->findOneBy(array('googleId' => $googleId));
     if (!$user instanceof $this->userClass) {
         //Check if Email was already present in database but not logged in via Google auth
         $user = $this->em->getRepository($this->userClass)->findOneBy(array('email' => $email));
         if (!$user instanceof $this->userClass) {
             //Last chance try looking for email address in username field
             $user = $this->em->getRepository($this->userClass)->findOneBy(array('username' => $email));
         }
     }
     return $user;
 }
开发者ID:bakie,项目名称:KunstmaanBundlesCMS,代码行数:17,代码来源:OAuthUserFinder.php

示例12: clearWebcode

 /**
  * Clears old webcode
  *
  * @param EntityManager $em            Entity Manager
  * @param string        $articleNumber Article
  *
  * @return void
  */
 private function clearWebcode($em, $articleNumber, $articleLanguage)
 {
     $webcode = $em->getRepository('Newscoop\\Entity\\Webcode')->createQueryBuilder('w')->leftJoin('w.article', 'a')->where('a.number = :number')->andWhere('a.language = :language')->setParameter('number', $articleNumber)->setParameter('language', $articleLanguage)->getQuery()->getOneOrNullResult();
     if ($webcode) {
         $em->remove($webcode);
         $em->flush();
     }
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:16,代码来源:GenerateWebcodeCommand.php

示例13: testFindingRepositoryClasses

 public function testFindingRepositoryClasses()
 {
     /// its useless now , but i will work on it soon
     $WriterRepository = $this->em->getRepository("ZF2EntityAuditTest\\Entity\\Writer");
     $ArticleRepository = $this->em->getRepository("ZF2EntityAuditTest\\Entity\\Article");
     $this->assertEquals("Doctrine\\ORM\\EntityRepository", get_class($WriterRepository));
     $this->assertEquals("Doctrine\\ORM\\EntityRepository", get_class($ArticleRepository));
 }
开发者ID:tawfekov,项目名称:zf2entityaudit,代码行数:8,代码来源:AuditTest.php

示例14: testReverseTransformNewUnknownEntity

 /**
  * @depends testReverseTransformNewKnownEntity
  */
 public function testReverseTransformNewUnknownEntity()
 {
     $transformer = $this->createTransformer();
     $tags = $this->createTagCollection();
     $tags = $transformer->reverseTransform("foo, bar, baz", $tags);
     $this->assertEquals(3, count($tags));
     $this->em->flush();
     $this->assertSame($this->em, $transformer->getOption('em'));
     $this->assertEquals(1, count($this->em->getRepository('Symfony\\Bundle\\DoctrineBundle\\Tests\\Form\\ValueTransformer\\Tag')->findAll()));
 }
开发者ID:rsky,项目名称:symfony,代码行数:13,代码来源:CollectionToStringTransformerTest.php

示例15: createCommentAction

 /**
     /**
 * Create comment
 *
 * @param Request $request
 * @param string  $slug
 * @throws NotFoundHttpException
 * @return array
 *
 * @Route("/{slug}/create-comment")
 * @Method("POST")
 * @Template("CoreBundle:Post:show.html.twig")
 */
 public function createCommentAction(Request $request, $slug)
 {
     //        exit(\Doctrine\Common\Util\Debug::dump($slug));
     //        var_dump($request); exit;
     $post = $this->em->getRepository('ModelBundle:Post')->findOneBy(array('slug' => $slug));
     if ($post === null) {
         throw createNotFoundException('Post Was Not Found');
     }
     $comment = new Comment();
     $comment->setPost($post);
     $form = $this->createForm(new CommentType(), $comment);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $this->em->persist($comment);
         $this->em->flush();
         $this->get('session')->getFlashBag()->add('success', 'Your comment was submitted successfully');
         return $this->redirect($this->generateUrl('blog_core_post_show', array('slug' => $post->getSlug())));
     }
     return array('post' => $post, 'form' => $form->createView());
 }
开发者ID:dinushjaykody,项目名称:symfony_blog,代码行数:33,代码来源:PostController.php


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