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


PHP ManagerRegistry::getManager方法代码示例

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


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

示例1: setUpDoctrine

 /**
  */
 protected function setUpDoctrine()
 {
     static::bootKernel();
     $this->container = static::$kernel->getContainer();
     $this->doctrine = $this->createDoctrineRegistry();
     $this->em = $this->doctrine->getManager();
     $this->loader = new Loader();
 }
开发者ID:jasongrimes,项目名称:stressmonkey,代码行数:10,代码来源:DoctrineTraits.php

示例2: isKnownEntityClassNamespace

 /**
  * Checks whether the given namespace is registered in the Doctrine
  *
  * @param string $namespace
  * @return bool
  */
 public function isKnownEntityClassNamespace($namespace)
 {
     foreach (array_keys($this->doctrine->getManagers()) as $name) {
         $namespaces = $this->doctrine->getManager($name)->getConfiguration()->getEntityNamespaces();
         if (in_array($namespace, $namespaces, true)) {
             return true;
         }
     }
     return false;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:16,代码来源:EntityClassResolver.php

示例3: createLike

 public function createLike(Post $post, $score)
 {
     // Récupère l'utilisateur courant
     $user = $this->tokenStorage->getToken()->getUser();
     // Création du postlike
     $postLike = new PostLike();
     $postLike->setScore($score);
     $postLike->setTarget($post);
     $postLike->setUser($user);
     // Sauvegarde
     $em = $this->doctrine->getManager();
     $em->persist($postLike);
     $em->flush($postLike);
 }
开发者ID:Peekmo,项目名称:lpdw-sources,代码行数:14,代码来源:LikeManager.php

示例4: send

 public function send()
 {
     $this->assertTransport();
     $marketingList = $this->emailCampaign->getMarketingList();
     /** @var EntityManager $manager */
     $manager = $this->registry->getManager();
     foreach ($this->getIterator() as $entity) {
         $to = $this->contactInformationFieldsProvider->getQueryContactInformationFields($marketingList->getSegment(), $entity, ContactInformationFieldsProvider::CONTACT_INFORMATION_SCOPE_EMAIL);
         try {
             $manager->beginTransaction();
             // Do actual send
             $this->transport->send($this->emailCampaign, $entity, [$this->getSenderEmail() => $this->getSenderName()], $to);
             // Mark marketing list item as contacted
             $marketingListItem = $this->marketingListItemConnector->contact($marketingList, $entity->getId());
             // Record email campaign contact statistic
             $statisticsRecord = new EmailCampaignStatistics();
             $statisticsRecord->setEmailCampaign($this->emailCampaign)->setMarketingListItem($marketingListItem);
             $manager->persist($statisticsRecord);
             $manager->flush();
             $manager->commit();
         } catch (\Exception $e) {
             $manager->rollback();
             if ($this->logger) {
                 $this->logger->error(sprintf('Email sending to "%s" failed.', implode(', ', $to)), array('exception' => $e));
             }
         }
     }
     $this->emailCampaign->setSent(true);
     $manager->persist($this->emailCampaign);
     $manager->flush();
 }
开发者ID:dairdr,项目名称:crm,代码行数:31,代码来源:EmailCampaignSender.php

示例5: getManager

 /**
  * @return ObjectManager
  */
 protected function getManager()
 {
     if (!$this->manager) {
         $this->manager = $this->doctrine->getManager();
     }
     return $this->manager;
 }
开发者ID:paulstoica,项目名称:platform,代码行数:10,代码来源:EmailBodySynchronizer.php

示例6: __construct

 /**
  * DiffManager constructor.
  * @param ManagerRegistry $managerRegistry
  * @param string          $recolnatAlias
  * @param string          $recolnatBufferAlias
  */
 public function __construct(ManagerRegistry $managerRegistry, $recolnatAlias, $recolnatBufferAlias)
 {
     $this->managerRegistry = $managerRegistry;
     $this->em = $managerRegistry->getManager('default');
     $this->recolnatAlias = $recolnatAlias;
     $this->recolnatBufferAlias = $recolnatBufferAlias;
 }
开发者ID:e-ReColNat,项目名称:recolnat-diff,代码行数:13,代码来源:DiffManager.php

示例7: __invoke

 /**
  * Retrieves a collection of resources.
  *
  * @param Request $request
  *
  * @return array|\Dunglas\ApiBundle\Model\PaginatorInterface|\Traversable
  *
  * @throws RuntimeException|RootNodeNotFoundException|RootMayNotBeMovedException|MissingParentCategoryException
  */
 public function __invoke(Request $request, $id)
 {
     list($resourceType) = $this->extractAttributes($request);
     $entity = $this->getItem($this->dataProvider, $resourceType, $id);
     $parentId = $request->request->get("parent");
     $parentEntity = $this->iriConverter->getItemFromIri($parentId);
     if ($parentEntity === null) {
         throw new MissingParentCategoryException($parentId);
     }
     if ($entity->getLevel() === 0) {
         throw new RootMayNotBeMovedException();
     }
     $entity->setParent($parentEntity);
     $this->registry->getManager()->flush();
     return new Response($request->request->get("parent"));
 }
开发者ID:fulcrum3d,项目名称:PartKeepr,代码行数:25,代码来源:MoveAction.php

示例8: __invoke

 /**
  * Retrieves a collection of resources.
  *
  * @param Request $request The request
  * @param int $id The ID of the part
  *
  * @return array|\Dunglas\ApiBundle\Model\PaginatorInterface|\Traversable
  *
  * @throws RuntimeException|RootNodeNotFoundException
  */
 public function __invoke(Request $request, $id)
 {
     list($resourceType) = $this->extractAttributes($request);
     $part = $this->getItem($this->dataProvider, $resourceType, $id);
     /**
      * @var $part Part
      */
     $quantity = $request->request->get("quantity");
     $user = $this->userService->getUser();
     $stock = new StockEntry(0 - intval($quantity), $user);
     if ($request->request->has("comment") && $request->request->get("comment") !== null) {
         $stock->setComment($request->request->get("comment"));
     }
     $part->addStockEntry($stock);
     $this->registry->getManager()->persist($stock);
     $this->registry->getManager()->flush();
     return $part;
 }
开发者ID:fulcrum3d,项目名称:PartKeepr,代码行数:28,代码来源:RemoveStockAction.php

示例9: isEntity

 /**
  * @param mixed $object
  *
  * @return bool
  */
 private function isEntity($object)
 {
     $isEntity = false;
     if (is_object($object)) {
         $class = $object instanceof Proxy ? get_parent_class($object) : get_class($object);
         if (null !== ($manager = $this->registry->getManagerForClass($class))) {
             $isEntity = !$this->registry->getManager()->getMetadataFactory()->isTransient($class);
         }
     }
     return $isEntity;
 }
开发者ID:Onneil,项目名称:dedipanel,代码行数:16,代码来源:DynamicFieldsTypeExtension.php

示例10: executeJob

 /**
  * @param string $jobType
  * @param string $jobName
  * @param array $configuration
  * @return JobResult
  */
 public function executeJob($jobType, $jobName, array $configuration = array())
 {
     // create and persist job instance and job execution
     $jobInstance = new JobInstance(self::CONNECTOR_NAME, $jobType, $jobName);
     $jobInstance->setCode($this->generateJobCode($jobName));
     $jobInstance->setLabel(sprintf('%s.%s', $jobType, $jobName));
     $jobInstance->setRawConfiguration($configuration);
     $jobExecution = new JobExecution();
     $jobExecution->setJobInstance($jobInstance);
     // persist batch entities
     $this->batchJobManager->persist($jobInstance);
     $this->batchJobManager->persist($jobExecution);
     // do job
     $jobResult = $this->doJob($jobInstance, $jobExecution);
     // EntityManager can be closed when there was an exception in flush method called inside some jobs execution
     // Can't be implemented right now due to OroEntityManager external dependencies
     // on ExtendManager and FilterCollection
     if (!$this->entityManager->isOpen()) {
         $this->managerRegistry->resetManager();
         $this->entityManager = $this->managerRegistry->getManager();
     }
     // flush batch entities
     $this->batchJobManager->flush($jobInstance);
     $this->batchJobManager->flush($jobExecution);
     // set data to JobResult
     $jobResult->setJobId($jobInstance->getId());
     $jobResult->setJobCode($jobInstance->getCode());
     // TODO: Find a way to work with multiple amount of job and step executions
     // TODO: https://magecore.atlassian.net/browse/BAP-2600
     /** @var JobExecution $jobExecution */
     $jobExecution = $jobInstance->getJobExecutions()->first();
     if ($jobExecution) {
         $stepExecution = $jobExecution->getStepExecutions()->first();
         if ($stepExecution) {
             $context = $this->contextRegistry->getByStepExecution($stepExecution);
             $jobResult->setContext($context);
         }
     }
     return $jobResult;
 }
开发者ID:xamin123,项目名称:platform,代码行数:46,代码来源:JobExecutor.php

示例11: __invoke

 /**
  * Retrieves a collection of resources.
  *
  * @param Request $request The request
  * @param int     $id      The ID of the part
  *
  * @throws RuntimeException|RootNodeNotFoundException
  *
  * @return array|\Dunglas\ApiBundle\Model\PaginatorInterface|\Traversable
  */
 public function __invoke(Request $request, $id)
 {
     list($resourceType) = $this->extractAttributes($request);
     $part = $this->getItem($this->dataProvider, $resourceType, $id);
     /*
      * @var $part Part
      */
     $quantity = $request->request->get('quantity');
     $user = $this->userService->getUser();
     $oldQuantity = $part->getStockLevel();
     $correctionQuantity = $quantity - $oldQuantity;
     if ($correctionQuantity != 0) {
         $stock = new StockEntry();
         $stock->setStockLevel($correctionQuantity);
         $stock->setUser($user);
         if ($request->request->has('comment') && $request->request->get('comment') !== null) {
             $stock->setComment($request->request->get('comment'));
         }
         $part->addStockLevel($stock);
         $this->registry->getManager()->persist($stock);
         $this->registry->getManager()->flush();
     }
     return $part;
 }
开发者ID:partkeepr,项目名称:PartKeepr,代码行数:34,代码来源:SetStockAction.php

示例12: loadNameMaps

 /**
  * Loads table name <-> entity class name maps
  */
 protected function loadNameMaps()
 {
     $this->tableToClassMap = [];
     $this->classToTableMap = [];
     $names = array_keys($this->doctrine->getManagers());
     foreach ($names as $name) {
         $manager = $this->doctrine->getManager($name);
         if ($manager instanceof EntityManager) {
             $allMetadata = $this->getAllMetadata($manager);
             foreach ($allMetadata as $metadata) {
                 $tableName = $metadata->getTableName();
                 if (!empty($tableName)) {
                     $className = $metadata->getName();
                     $this->tableToClassMap[$tableName] = $className;
                     $this->classToTableMap[$className] = $tableName;
                 }
             }
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:23,代码来源:EntityMetadataHelper.php

示例13: send

 public function send()
 {
     if (!$this->assertTransport()) {
         return;
     }
     $marketingList = $this->emailCampaign->getMarketingList();
     if (is_null($marketingList)) {
         return;
     }
     $iterator = $this->getIterator();
     if (is_null($iterator)) {
         return;
     }
     /** @var EntityManager $manager */
     $manager = $this->registry->getManager();
     $emailFields = $this->contactInformationFieldsProvider->getMarketingListTypedFields($marketingList, ContactInformationFieldsProvider::CONTACT_INFORMATION_SCOPE_EMAIL);
     foreach ($iterator as $entity) {
         $to = $this->contactInformationFieldsProvider->getTypedFieldsValues($emailFields, $entity);
         $to = array_unique($to);
         try {
             $manager->beginTransaction();
             // Do actual send
             $this->transport->send($this->emailCampaign, $entity, [$this->getSenderEmail() => $this->getSenderName()], $to);
             $statisticsRecord = $this->statisticsConnector->getStatisticsRecord($this->emailCampaign, $entity);
             // Mark marketing list item as contacted
             $statisticsRecord->getMarketingListItem()->contact();
             $manager->flush($statisticsRecord);
             $manager->commit();
         } catch (\Exception $e) {
             $manager->rollback();
             if ($this->logger) {
                 $this->logger->error(sprintf('Email sending to "%s" failed.', implode(', ', $to)), ['exception' => $e]);
             }
         }
     }
     $this->emailCampaign->setSent(true);
     $manager->persist($this->emailCampaign);
     $manager->flush();
 }
开发者ID:antrampa,项目名称:crm,代码行数:39,代码来源:EmailCampaignSender.php

示例14: __construct

 public function __construct(ManagerRegistry $doctrine, TwigEngine $twig, $template_class)
 {
     $this->dm = $doctrine->getManager();
     $this->twig = $twig;
     $this->template_class = $template_class;
 }
开发者ID:studiocaramia,项目名称:redking_MailBundle,代码行数:6,代码来源:MessageMaker.php

示例15: initialize

 /**
  * Initialize environment
  */
 protected function initialize()
 {
     $this->entityManager = $this->managerRegistry->getManager();
 }
开发者ID:antrampa,项目名称:platform,代码行数:7,代码来源:JobExecutor.php


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