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


PHP Registry::getManager方法代码示例

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


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

示例1: loadUserByOAuthUserResponse

 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $name = $response->getRealName();
     $email = $response->getEmail();
     $clientId = $response->getUsername();
     $token = $response->getAccessToken();
     $user = $this->doctrine->getRepository('UserUserBundle:Users')->findOneByOAuthUser($clientId);
     /** @var Users $user */
     if (!$user) {
         $service = $response->getResourceOwner()->getName();
         $setter = 'set' . ucfirst($service);
         $setterId = $setter . "Id";
         $setterToken = $setter . 'AccessToken';
         $user = new Users();
         $user->setRealname($name);
         $user->setUsername($email);
         $user->{$setterId}($clientId);
         $user->{$setterToken}($token);
         $user->setPassword(sha1($clientId));
         $roles = $this->doctrine->getRepository('UserUserBundle:Roles')->findOneBy(['role' => 'ROLE_USER']);
         $user->addRole($roles);
         $this->doctrine->getManager()->persist($user);
         $this->doctrine->getManager()->flush();
         $userId = $user->getId();
     } else {
         $userId = $user->getId();
     }
     if (!$userId) {
         throw new UsernameNotFoundException('Возникла проблема добавления или определения пользователя');
     }
     return $this->loadUserByUsername($userId);
 }
开发者ID:rdbn,项目名称:shopsnmarkets,代码行数:32,代码来源:OAuthProvider.php

示例2: update

 public function update(Worker $worker)
 {
     /** @var EntityManager $em */
     $em = $this->doctrine->getManager();
     $exception = null;
     $i = 0;
     while ($i < 5) {
         try {
             $worker = $this->getWorker(['queue' => $worker->getQueue(), 'instance' => $worker->getInstance(), 'host' => $worker->getHost()]);
             $em->persist($worker);
             $em->flush();
             return;
         } catch (\Exception $e) {
             // the connection might have "gone away"
             $this->logger->warning("Error while updating worker entity", ['message' => $e->getMessage()]);
             $exception = $e;
             $this->doctrine->resetManager();
             $em = $this->doctrine->getManager();
             $em->getConnection()->close();
             $em->getConnection()->connect();
         }
         $i++;
     }
     throw new ApplicationException("Unable to update worker entity", $exception);
 }
开发者ID:keboola,项目名称:syrup-queue,代码行数:25,代码来源:WorkerManager.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->doctrine = $this->getContainer()->get('doctrine');
     // get all cities
     $qb = $this->doctrine->getManager()->createQueryBuilder();
     $qb->select('ct')->from('HelperBundle:City', 'ct')->where('ct.geoCityId IS NOT NULL')->orderBy('ct.id', 'ASC');
     $cities = $qb->getQuery()->getResult();
     $connection = $this->doctrine->getConnection();
     foreach ($cities as $city) {
         $output->write('Updating data of old city #' . $city->getId());
         $sql = "SELECT cg_gct.* FROM `chromedia_global`.`geo_cities` cg_gct WHERE cg_gct.`id` = ?";
         $statement = $connection->prepare($sql);
         $statement->bindValue(1, $city->getGeoCityId());
         $statement->execute();
         $globalCityData = $statement->fetch();
         if ($globalCityData) {
             $updateSql = "UPDATE `cities` SET `id` = :geoCityId, `name` = :geoCityName, `slug` = :geoCitySlug WHERE `old_id` = :oldId";
             $updateStatement = $connection->prepare($updateSql);
             $updateStatement->bindValue('geoCityId', $globalCityData['id']);
             $updateStatement->bindValue('geoCityName', $globalCityData['name']);
             $updateStatement->bindValue('geoCitySlug', $globalCityData['slug']);
             $updateStatement->bindValue('oldId', $city->getOldId());
             $updateStatement->execute();
             $output->writeln(' OK');
         } else {
             $output->writeln(' Not found');
         }
     }
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:29,代码来源:UpdateCitiesDataFromGlobalDataCommand.php

示例4: getEntityManager

 /**
  * @return EntityManager
  */
 private function getEntityManager()
 {
     if (!$this->doctrine) {
         $this->doctrine = $this->container->get('doctrine');
     }
     return $this->doctrine->getManager($this->entityManagerName);
 }
开发者ID:mcfedr,项目名称:doctrine-delay-queue-driver-bundle,代码行数:10,代码来源:DoctrineDelayTrait.php

示例5: dispatch

 /**
  * Dispatch a covoit using database alerts.
  * Find matching alerts, create notifications and send them.
  *
  * @param Covoit $covoit
  */
 public function dispatch(Covoit $covoit)
 {
     /** @var EntityManager $em */
     $em = $this->doctrine->getManager();
     /*
      * We find all the alerts and try to match these objects with the covoit. However, as the number of result could
      * be big, we use some simple conditions to limit results : he startCity, the endCity and the price. Matching
      * date is difficult directly in SQL as the condition depends of which fields are filled.
      */
     /** @var CovoitAlert[] $alerts */
     $alerts = $em->createQueryBuilder()->select('a, s, e, u')->from('EtuModuleCovoitBundle:CovoitAlert', 'a')->leftJoin('a.startCity', 's')->leftJoin('a.endCity', 'e')->leftJoin('a.user', 'u')->where('a.startCity = :startCiy OR a.startCity IS NULL')->andWhere('a.endCity = :endCity OR a.endCity IS NULL')->andWhere('a.priceMax <= :price OR a.priceMax IS NULL')->setParameters(['startCiy' => $covoit->getStartCity()->getId(), 'endCity' => $covoit->getEndCity()->getId(), 'price' => $covoit->getPrice()])->getQuery()->getResult();
     // Notifications - Send only one notification per user, even if covoit match several alerts
     $notifications = [];
     foreach ($alerts as $alert) {
         if ($this->match($alert, $covoit)) {
             $notif = $this->createNotification($covoit);
             $notif->setEntityId($alert->getId());
             $notif->setAuthorId($covoit->getAuthor()->getId());
             $notifications[$alert->getUser()->getId()] = $notif;
         }
     }
     // Send the notifications
     foreach ($notifications as $notification) {
         $this->sender->send($notification);
     }
 }
开发者ID:ChrisdAutume,项目名称:EtuUTT,代码行数:32,代码来源:NotificationsDispatcher.php

示例6: unsubscribe

 /**
  * @param string $entityType
  * @param integer $entityId
  * @param User $user
  * @return bool
  */
 public function unsubscribe(User $user, $entityType, $entityId)
 {
     /** @var $em EntityManager */
     $em = $this->doctrine->getManager();
     $em->createQueryBuilder()->delete('EtuCoreBundle:Subscription', 's')->andWhere('s.entityId = :entityId')->andWhere('s.entityType = :entityType')->andWhere('s.user = :user')->setParameter('entityType', $entityType)->setParameter('entityId', $entityId)->setParameter('user', $user->getId())->getQuery()->execute();
     return true;
 }
开发者ID:ChrisdAutume,项目名称:EtuUTT,代码行数:13,代码来源:SubscriptionsManager.php

示例7: getInstitutionsWithNoState

 private function getInstitutionsWithNoState()
 {
     $qb = $this->doctrine->getManager()->createQueryBuilder();
     $qb->select('inst')->from('InstitutionBundle:Institution', 'inst')->where('inst.state IS NULL');
     $result = $qb->getQuery()->getResult();
     return $result;
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:7,代码来源:MigrateStateTextDataCommand.php

示例8: contentBlock

 /**
  * @param string $blockName
  * @param array  $options
  * @param string $default
  * @return string
  */
 public function contentBlock($blockName, $options = array(), $default = null)
 {
     $em = $this->doctrine->getManager();
     $repository = $em->getRepository('GlavwebContentBlockBundle:ContentBlock');
     $contentBlock = $repository->findOneByName($blockName);
     $tag = isset($options['tag']) ? $options['tag'] : 'div';
     $attr = isset($options['attr']) ? $options['attr'] : array();
     if (isset($options['class'])) {
         $attr['class'] = $options['class'];
     }
     if (isset($options['href'])) {
         $attr['href'] = $options['href'];
     }
     if (!$contentBlock) {
         $contentBlock = new ContentBlock();
         $contentBlock->setName($blockName);
         $contentBlock->setBody($default ? $default : $blockName);
         $em->persist($contentBlock);
         $em->flush();
     }
     $contentEditable = '';
     $dataBlockName = '';
     $isEditable = $this->request && $this->request->get('contenteditable') && $this->securityContext->isGranted('ROLE_ADMIN');
     if ($isEditable) {
         $contentEditable = ' contenteditable="true"';
         $dataBlockName = ' data-block-name="' . $blockName . '"';
         $attr['class'] = isset($attr['class']) ? $attr['class'] . ' js-content-block' : 'js-content-block';
     }
     $attrParts = array();
     foreach ($attr as $attrName => $value) {
         $attrParts[] = sprintf('%s="%s"', $attrName, $value);
     }
     return '<' . $tag . ' ' . implode(' ', $attrParts) . ' ' . $contentEditable . $dataBlockName . '>' . $contentBlock->getBody() . '</' . $tag . '>';
 }
开发者ID:glavweb,项目名称:GlavwebContentBlockBundle,代码行数:40,代码来源:ContentBlockExtension.php

示例9: __construct

 public function __construct(Registry $doctrine, Session $session, Logger $logger, Parameters $parameters)
 {
     $this->doctrine = $doctrine;
     $this->session = $session;
     $this->logger = $logger;
     $this->parameters = $parameters;
     $this->emFrom = $this->doctrine->getManager($this->parameters->getManagerFrom());
     $this->emTo = $this->doctrine->getManager($this->parameters->getManagerTo());
     $fromRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerFrom());
     $fromRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     //$toRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerTo() );
     //$toRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     $this->fromAnalyzer = new PgAnalyzer($this->logger, $fromRetriever);
     //$this->toAnalyzer = new PgAnalyzer($this->logger, $toRetriever);
     if ($this->session->has(CompareStructure::SESSION_FROM_KEY)) {
         $this->fromAnalyzer->setSchemas($this->session->get(CompareStructure::SESSION_FROM_KEY));
         $this->fromAnalyzer->initTables();
     } else {
         throw new SyncException('No source data');
     }
     /*if($this->session->has(CompareStructure::SESSION_TO_KEY)){
           $this->toAnalyzer->setSchemas($this->session->get(CompareStructure::SESSION_TO_KEY));
           $this->toAnalyzer->initTables();
       }else{
           throw new SyncException('No targeted data');
       }*/
 }
开发者ID:rombar3,项目名称:PgExplorer,代码行数:27,代码来源:SyncData.php

示例10: expireRegistrationApplication

 private function expireRegistrationApplication(RegistrationApplication $registrationApplication)
 {
     $registrationApplication->setExpireAt(null);
     $em = $this->doctrine->getManager();
     $em->persist($registrationApplication);
     $em->flush();
 }
开发者ID:vansanblch,项目名称:nour-tools,代码行数:7,代码来源:RegistrationExecutor.php

示例11: startAutoReply

 /**
  * @param Ticket $ticket
  */
 protected function startAutoReply(Ticket $ticket)
 {
     $ticketText = $ticket->getSubject() . ' ' . $ticket->getDescription();
     $repository = $this->registry->getManager()->getRepository('DiamanteDeskBundle:Article');
     $results = [];
     /** @var Article $article */
     foreach ($repository->findByStatus(1) as $article) {
         $articleText = $article->getTitle() . ' ' . $article->getContent();
         $results[$article->getId()] = $this->compare($ticketText, $articleText);
     }
     $maxResult = max($results);
     /**
      * TODO: should be configured by admin
      */
     if ($maxResult < 3) {
         return;
     }
     $articleId = array_search(max($results), $results);
     /**
      * TODO: should be extracted from previous call of $repository->getAll()
      */
     $article = $repository->find($articleId);
     /**
      * TODO: should be extracted from configuration???
      */
     $user = User::fromString('oro_1');
     $content = $this->getAutoReplayNoticeHtml() . $article->getContent();
     $comment = new Comment($content, $ticket, $user, false);
     $this->registry->getManager()->persist($comment);
     $this->uow->computeChangeSet($this->em->getClassMetadata($comment->getClassName()), $comment);
     /**
      * TODO: should be executed workflowEven?
      */
 }
开发者ID:northdakota,项目名称:diamantedesk-application,代码行数:37,代码来源:ArticleAutoReplyServiceImpl.php

示例12: getAccessTokenWithCheckingExpiration

 /**
  * @param UserEmailOrigin $origin
  *
  * @return string
  */
 public function getAccessTokenWithCheckingExpiration(UserEmailOrigin $origin)
 {
     $expiresAt = $origin->getAccessTokenExpiresAt();
     $utcTimeZone = new \DateTimeZone('UTC');
     $now = new \DateTime('now', $utcTimeZone);
     $token = $origin->getAccessToken();
     //if token had been expired, the new one must be generated and saved to DB
     if ($now > $expiresAt && $this->configManager->get('oro_imap.enable_google_imap')) {
         $parameters = ['refresh_token' => $origin->getRefreshToken(), 'grant_type' => 'refresh_token'];
         $attemptNumber = 0;
         do {
             $attemptNumber++;
             $response = $this->doHttpRequest($parameters);
             if (!empty($response['access_token'])) {
                 $token = $response['access_token'];
                 $origin->setAccessToken($token);
                 $newExpireDate = new \DateTime('+' . $response['expires_in'] . ' seconds', $utcTimeZone);
                 $origin->setAccessTokenExpiresAt($newExpireDate);
                 $this->doctrine->getManager()->persist($origin);
                 $this->doctrine->getManager()->flush();
             }
         } while ($attemptNumber <= self::RETRY_TIMES && empty($response['access_token']));
     }
     return $token;
 }
开发者ID:snorchel,项目名称:platform,代码行数:30,代码来源:ImapEmailGoogleOauth2Manager.php

示例13: postTask

 public function postTask(Worker $worker, array $options = null)
 {
     if ($worker instanceof DoctrineAwareWorker) {
         if ($this->doctrine) {
             $this->doctrine->getManager()->clear();
         }
     }
 }
开发者ID:mcfedr,项目名称:job-manager-bundle,代码行数:8,代码来源:DoctrineListener.php

示例14: initKernel

 private static function initKernel()
 {
     static::$kernel = static::createKernel();
     static::$kernel->boot();
     static::$container = static::$kernel->getContainer();
     static::$doctrine = static::$container->get('doctrine');
     static::$om = static::$doctrine->getManager();
 }
开发者ID:eugene-matvejev,项目名称:battleship-game-api,代码行数:8,代码来源:AbstractKernelTestSuite.php

示例15: getEntityIdentifier

 /**
  * @param object $entity
  *
  * @return string|null
  */
 public function getEntityIdentifier($entity)
 {
     if (!$this->doctrine instanceof Registry) {
         return null;
     }
     $ids = $this->doctrine->getManager()->getClassMetadata(get_class($entity))->getIdentifierValues($entity);
     return $ids ? self::IDENTIFIER_PREFIX . implode(self::IDENTIFIER_SEPARATOR, $ids) : null;
 }
开发者ID:anime-db,项目名称:cache-time-keeper-bundle,代码行数:13,代码来源:CacheKeyBuilder.php


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