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


PHP Registry::getEntityManager方法代码示例

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


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

示例1: getTodayTimeline

 /**
  * get today timeline json
  *
  * @return array|null timeline or null
  */
 public function getTodayTimeline()
 {
     $get_query = ['user_id' => $this->user->getTwitterId()];
     $today = (new \DateTime())->format('Y-m-d');
     $since_id_at = $this->user->getSinceIdAt();
     // 今日の始点ツイートのsince_idが無ければsince_idを計算後、timlineを返す
     if ($since_id_at === null || $since_id_at->format('Y-m-d') !== $today) {
         $result = $this->findIdRangeByDate(new \DateTime(), $get_query);
         // エラーメッセージの場合
         if (isset($result['error'])) {
             return $result;
         }
         // since_idのDB登録
         $user = $this->user;
         $user->setTodaySinceId($result['since_id']);
         $user->setSinceIdAt(new \DateTime());
         $user->setUpdateAt(new \DateTime());
         $em = $this->doctrine->getEntityManager();
         $user = $em->merge($user);
         $em->persist($user);
         $em->flush();
         return $result['timeline_json'];
     }
     // since_idがあればget_queryに指定して今日のつぶやき一覧をapiから取得
     $today_since_id = $this->user->getTodaySinceId();
     if ($today_since_id !== '') {
         $get_query['since_id'] = $today_since_id;
         // since_idが無ければ200件まで取得 今日以前のつぶやきが存在しないアカウントなど
     } else {
         $get_query['count'] = '200';
     }
     $timeline = $this->callStatusesUserTimeline($get_query);
     return $timeline;
 }
开发者ID:ryota-murakami,项目名称:daily-tweet,代码行数:39,代码来源:TwitterAPI.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     $this->mediaService = $this->getContainer()->get('services.doctor.media');
     $this->doctrine = $this->getContainer()->get('doctrine');
     $qb = $this->doctrine->getEntityManager()->createQueryBuilder();
     $qb->select('d, m')->from('DoctorBundle:Doctor', 'd')->innerJoin('d.media', 'm');
     $doctors = $qb->getQuery()->getResult();
     $doctorDirectory = $this->getWebRootDirectory();
     $logoSizes = $this->mediaService->getSizesByType(DoctorMediaService::LOGO_TYPE_IMAGE);
     foreach ($doctors as $doctor) {
         $this->output->writeln("Migrate images of Doctor #{$doctor->getId()}");
         $this->output->write("    ");
         if ($media = $doctor->getMedia()) {
             $doctorFile = $doctorDirectory . '/' . $media->getName();
             if (\file_exists($doctorFile)) {
                 // resize the image
                 $this->mediaService->resize($media, $logoSizes);
                 $this->output->writeln('Ok');
             } else {
                 $this->output->writeln('Not found');
             }
         } else {
             $this->output->writeln('No media');
         }
     }
     $this->output->writeln('All done');
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:28,代码来源:MigrateDoctorImagesCommand.php

示例3: getLogClassByName

 /**
  * Find an instance of LogClass by class name. If class exists and there is no record yet, a new LogClass will be saved
  * 
  * @param string $className
  * @return \HealthCareAbroad\LogBundle\Entity\LogClass
  */
 public function getLogClassByName($className)
 {
     if (!\class_exists($className)) {
         throw ListenerException::logClassDoesNotExist($className);
     }
     //         if (\array_key_exists($className, self::$logClassMap)) {
     //             $logClass = self::$logClassMap[$className];
     //         }
     //         else {
     //             $logClass = $this->doctrine->getRepository('LogBundle:LogClass')->findOneBy(array('name' => $className));
     //             if (!$logClass) {
     //                 $logClass = new LogClass();
     //                 $logClass->setName($className);
     //                 $this->saveLogClass($logClass);
     //             }
     //             else {
     //                 self::$logClassMap[$className] = $logClass;
     //             }
     //         }
     $logClass = $this->doctrine->getEntityManager('logger')->getRepository('LogBundle:LogClass')->findOneBy(array('name' => $className));
     if (!$logClass) {
         $logClass = new LogClass();
         $logClass->setName($className);
         $this->saveLogClass($logClass);
     }
     return $logClass;
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:33,代码来源:LogService.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     $this->doctrine = $this->getContainer()->get('doctrine');
     $entity = $input->getArgument('entity');
     $property = $input->getArgument('property');
     $width = $input->getArgument('width');
     $height = $input->getArgument('height');
     $size = array($width . 'x' . $height);
     $cropImage = $input->getOption('crop-image');
     $qb = $this->doctrine->getEntityManager()->createQueryBuilder();
     $qb->select('a')->from($entity, 'a')->where("a.{$property} IS NOT NULL");
     if ($entityId = $input->getOption('entity-id')) {
         $qb->andWhere('a.id = :id')->setParameter('id', $entityId);
     }
     $objects = $qb->getQuery()->getResult();
     $entityArr = explode(':', $entity);
     if ($entityArr[1] == 'InstitutionMedicalCenter') {
         $entityArr[1] = 'institution';
     }
     $mediaServiceName = 'services.' . lcfirst($entityArr[1]) . '.media';
     $mediaService = $this->getContainer()->get($mediaServiceName);
     $propertyGetMethod = 'get' . ucfirst($property);
     foreach ($objects as $each) {
         $media = $each->{$propertyGetMethod}();
         if ($media && $mediaService->getFilesystem()->has($media->getName())) {
             $this->output->write('Resizing image: ' . $media->getName() . ' (id: ' . $media->getId() . ') ... ');
             $mediaService->resize($media, $size, $cropImage);
             $this->output->writeln('DONE');
         }
     }
     $this->output->writeln('END OF SCRIPT');
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:33,代码来源:ResizeImageThumbnailsCommand.php

示例5: onAdd

 /**
  * Listener for event.institution_user.add event. Will delete used invitation
  * 
  * @param CreateInstitutionUserEvent $event
  */
 public function onAdd(CreateInstitutionUserEvent $event)
 {
     if ($invitation = $event->getUsedInvitation()) {
         $em = $this->doctrine->getEntityManager();
         $em->remove($invitation);
         $em->flush();
     }
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:13,代码来源:InstitutionUserListener.php

示例6: storeLog

 /**
  * @see StoreImplementationInterface::storeLog()
  */
 public function storeLog($time, $name, $tag, $version)
 {
     $em = $this->doctrine->getEntityManager();
     $log = new Log();
     $log->setTime(number_format($time, 4));
     $log->setName($name);
     $log->setTag($tag);
     $log->setVersion($version);
     $log->setExecutions(1);
     $em->persist($log);
     $em->flush();
 }
开发者ID:urodoz,项目名称:execution-stats,代码行数:15,代码来源:DoctrineImplementation.php

示例7: UserEditProfile

 /**
  * @param Request $request
  * @param $user
  * @return bool|Form|FormInterface
  */
 public function UserEditProfile(Request $request, $user)
 {
     $form = $this->FormFactory->create('profile_edit', $user);
     if ($request->getMethod() === 'POST') {
         $form->handleRequest();
         if ($form->isValid()) {
             $user = $form->getData();
             $em = $this->doctrine->getEntityManager();
             $em->persist($user);
             $em->flush();
             return true;
         }
     }
     return $form;
 }
开发者ID:Roman-Savchenko,项目名称:Bug_Tracker,代码行数:20,代码来源:UserEditProfileContainer.php

示例8: cleanUpUserContactDetails

 private function cleanUpUserContactDetails()
 {
     $em = $this->doctrine->getEntityManager();
     $qb = $em->createQueryBuilder();
     $qb->select('a, b')->from('UserBundle:InstitutionUser', 'a')->innerJoin('a.contactDetails', 'b');
     $users = $qb->getQuery()->getResult();
     foreach ($users as $user) {
         $this->output->write('Cleaning up for user #' . $user->getId() . ' [');
         foreach ($user->getContactDetails() as $contactDetail) {
             $number = $contactDetail->getNumber();
             if (!\is_numeric($number)) {
                 $number = \preg_replace('/\\D/', '', $number);
             }
             $contactDetail->setNumber((int) $number);
             if (!$number || strlen($number) < 5) {
                 $contactDetail->setIsInvalid(true);
             }
             $contactDetail->setFromNewWidget(true);
             $em->persist($contactDetail);
             $this->output->write('.');
         }
         $this->output->writeln('] Done.');
     }
     $em->flush();
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:25,代码来源:CleanUpContactDetailsCommand.php

示例9: testGetUnknownEntityManager

 public function testGetUnknownEntityManager()
 {
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $registry = new Registry($container, array(), array(), 'default', 'default');
     $this->setExpectedException('InvalidArgumentException', 'Doctrine ORM Manager named "default" does not exist.');
     $registry->getEntityManager('default');
 }
开发者ID:laubosslink,项目名称:lab,代码行数:7,代码来源:RegistryTest.php

示例10: removeTreatment

 public function removeTreatment(Treatment $treatment)
 {
     $em = $this->doctrine->getEntityManager();
     $em->remove($treatment);
     $em->flush();
     return true;
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:7,代码来源:TermsService.php

示例11: IssueRegistration

 /**
  * @param Request $request
  * @return Form|FormInterface
  */
 public function IssueRegistration(Request $request)
 {
     $form = $this->FormFactory->create('form_issue_registration', null);
     if ($request->getMethod() === 'POST') {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $issue = $form->getData();
             $em = $this->doctrine->getEntityManager();
             $em->persist($issue);
             $update = $issue->getCreated();
             $issue->setUpdated($update);
             $em->flush();
             return true;
         }
     }
     return $form;
 }
开发者ID:Roman-Savchenko,项目名称:Bug_Tracker,代码行数:21,代码来源:IssueRegistrationContainer.php

示例12: logException

 /**
  * TODO: copied this to ErrorLogService; use that instead
  *
  * @param \Exception $exception
  */
 public function logException(\Exception $exception)
 {
     $errorLog = new ErrorLog();
     $errorLog->setErrorType(ErrorType::EXCEPTION);
     $errorLog->setMessage($exception->getMessage());
     $errorLog->setStacktrace($exception->getTraceAsString());
     $errorLog->setHttpUserAgent(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '');
     $errorLog->setRemoteAddress(isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '');
     $errorLog->setServerJSON(\json_encode($_SERVER));
     $em = $this->doctrine->getEntityManager('logger');
     if (!$em->isOpen()) {
         $this->doctrine->resetEntityManager('logger');
         $em = $this->doctrine->getEntityManager('logger');
     }
     $em->persist($errorLog);
     $em->flush();
     // save log
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:23,代码来源:KernelExceptionListener.php

示例13: deleteMailsByIds

 /**
  * 
  * @param array $ids
  * @return void|multitype:
  */
 public function deleteMailsByIds(array $ids = array())
 {
     if (!count($ids)) {
         return;
     }
     $qb = $this->doctrine->getEntityManager()->createQueryBuilder();
     $result = $qb->select('a')->delete('MailerBundle:MailQueue', 'a')->where($qb->expr()->in('a.id', $ids))->getQuery()->getResult();
     return $result;
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:14,代码来源:MailerQueue.php

示例14: deleteDraftInstitutionSpecialization

 /** TODO: DEPRECATED ??
  * Remove draft institution specialization and associated procedure types
  *
  * @param Institution $institution
  * @param int $institutionSpecializationId
  * @throws Exception
  * @return InstitutionSpecialization $institutionSpecialization
  */
 public function deleteDraftInstitutionSpecialization(Institution $institution, $institutionSpecializationId)
 {
     $em = $this->doctrine->getEntityManager();
     //TODO: check that the institution owns the center.
     $center = $em->getRepository('InstitutionBundle:InstitutionSpecialization')->find($institutionSpecializationId);
     if (InstitutionMedicalCenterStatus::DRAFT != $center->getStatus()) {
         throw new Exception('Delete operation not allowed.');
     }
     //NOTE: Supposedly a DRAFT institution specialization will have no procedure types
     // so the loop below will never run. But this specification can change.
     //TODO: Use DQL DELETE statement to delete multiple entities of a type with a single command and without hydrating these entities
     foreach ($center->getInstitutionTreatments() as $entity) {
         $em->remove($entity);
     }
     $em->remove($center);
     $em->flush();
     return $center;
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:26,代码来源:InstitutionSpecializationService.php

示例15: save

 /**
  * Save institution
  * 
  * @param Institution $institution
  */
 public function save(Institution $institution)
 {
     $em = $this->doctrine->getEntityManager();
     $em->persist($institution);
     $em->flush();
     // get the memcache key for this institution
     //         $memcacheKey = $this->memcacheKeyFactory->generate('institution_entity', array('id' => $institution->getId()), array('institutionId' => $institution->getId()));
     //         // delete this from memcache
     //         $this->memcache->delete($memcacheKey);
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:15,代码来源:InstitutionFactory.php


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