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


PHP ManagerRegistry::getManager方法代码示例

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


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

示例1: __construct

 /**
  * DiffAbstract constructor.
  * @param ManagerRegistry $managerRegistry
  * @param int             $maxNbSpecimenPerPass
  */
 public function __construct(ManagerRegistry $managerRegistry, $maxNbSpecimenPerPass)
 {
     $this->maxNbSpecimenPerPass = $maxNbSpecimenPerPass;
     $this->managerRegistry = $managerRegistry;
     $this->emR = $managerRegistry->getManager('default');
     $this->emB = $managerRegistry->getManager('buffer');
 }
开发者ID:e-ReColNat,项目名称:recolnat-diff,代码行数:12,代码来源:AbstractDiff.php

示例2: prepareDatabase

 private function prepareDatabase()
 {
     /** @var EntityManager $em */
     $em = $this->registry->getManager();
     $tool = new SchemaTool($em);
     $tool->createSchema($em->getMetadataFactory()->getAllMetadata());
 }
开发者ID:karol-wojcik,项目名称:serializer,代码行数:7,代码来源:IntegrationTest.php

示例3: onLexikjwtauthenticationOnjwtcreated

 public function onLexikjwtauthenticationOnjwtcreated(JWTCreatedEvent $event)
 {
     $em = $this->registry->getManager();
     $data = $event->getData();
     $data['wownewfield'] = 'muchcool';
     $event->setData($data);
 }
开发者ID:jschroed91,项目名称:symfony-oauth-example,代码行数:7,代码来源:JWTCreatedListener.php

示例4: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if ($options['em'] === null) {
         $em = $this->registry->getManagerForClass($options['class']);
     } else {
         $em = $this->registry->getManager($options['em']);
     }
     $repository = $em->getRepository($options['class']);
     $entities = $repository->findAll();
     /** @var ClassMetadataInfo $classMetadata */
     $classMetadata = $em->getClassMetadata($options['class']);
     $identifierField = $classMetadata->getSingleIdentifierFieldName();
     $choiceLabels = [];
     /** @var AddressType $entity */
     foreach ($entities as $entity) {
         $pkValue = $classMetadata->getReflectionProperty($identifierField)->getValue($entity);
         if ($options['property']) {
             $value = $classMetadata->getReflectionProperty($options['property'])->getValue($entity);
         } else {
             $value = (string) $entity;
         }
         $choiceLabels[$pkValue] = $this->translator->trans('orob2b.customer.customer_typed_address_with_default_type.choice.default_text', ['%type_name%' => $value]);
     }
     $builder->add('default', 'choice', ['choices' => $choiceLabels, 'multiple' => true, 'expanded' => true, 'label' => false])->addViewTransformer(new AddressTypeDefaultTransformer($em));
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:28,代码来源:CustomerTypedAddressWithDefaultType.php

示例5: onConsoleTerminate

 /**
  * @param ConsoleTerminateEvent $event
  */
 public function onConsoleTerminate(ConsoleTerminateEvent $event)
 {
     if ($event->getCommand() instanceof UpdateSchemaDoctrineCommand) {
         $output = $event->getOutput();
         $input = $event->getInput();
         if ($input->getOption('force')) {
             $result = $this->fulltextIndexManager->createIndexes();
             $output->writeln('Schema update and create index completed.');
             if ($result) {
                 $output->writeln('Indexes were created.');
             }
         }
     }
     if ($event->getCommand() instanceof UpdateSchemaCommand) {
         $entities = $this->registry->getRepository('OroSearchBundle:UpdateEntity')->findAll();
         if (count($entities)) {
             $em = $this->registry->getManager();
             foreach ($entities as $entity) {
                 $job = new Job(ReindexCommand::COMMAND_NAME, ['class' => $entity->getEntity()]);
                 $em->persist($job);
                 $em->remove($entity);
             }
             $em->flush($job);
         }
     }
 }
开发者ID:northdakota,项目名称:platform,代码行数:29,代码来源:UpdateSchemaDoctrineListener.php

示例6: isApplicableOnMarketingList

 /**
  * Checks the object is an instance of a given class.
  *
  * @param MarketingList $marketingList
  * @return bool
  */
 public function isApplicableOnMarketingList($marketingList)
 {
     if ($marketingList instanceof MarketingList) {
         return (bool) $this->registry->getManager()->getRepository('OroCRMMailChimpBundle:StaticSegment')->findOneBy(['marketingList' => $marketingList]);
     }
     return false;
 }
开发者ID:aculvi,项目名称:OroCRMMailChimpBundle,代码行数:13,代码来源:MarketingListPlaceholderFilter.php

示例7: getObjectManager

 /**
  * @param string $name
  *
  * @return \Doctrine\Common\Persistence\ObjectManager
  *
  * @throws \Exception
  */
 private function getObjectManager($name)
 {
     if (null === ($manager = $this->doctrine->getManager($name))) {
         throw new \Exception(sprintf('Can\'t find doctrine manager named "%s"'), $name);
     }
     return $manager;
 }
开发者ID:Devolicious,项目名称:rad-fixtures-load,代码行数:14,代码来源:Loader.php

示例8: updateToken

 /**
  * Updates a Token.
  *
  * @param Token   $token
  * @param Boolean $andFlush Whether to flush the changes (default true)
  */
 public function updateToken(Token $token, $andFlush = true)
 {
     $this->doctrine->getManager()->persist($token);
     if ($andFlush) {
         $this->doctrine->getManager()->flush();
     }
 }
开发者ID:treehouselabs,项目名称:keystone-bundle,代码行数:13,代码来源:TokenManager.php

示例9: getCollection

 /**
  * @param string    $institutionCode
  * @param string    $collectionCode
  * @param User|null $user
  * @return Collection|AccessDeniedException
  */
 public function getCollection($institutionCode, $collectionCode, User $user = null)
 {
     $collection = $this->managerRegistry->getManager('default')->getRepository('AppBundle:Collection')->findOneByCollectionAndInstitution($institutionCode, $collectionCode);
     if (!is_null($user) && !is_null($collection)) {
         $this->checkUserRight($user, $collection);
     }
     return $collection;
 }
开发者ID:e-ReColNat,项目名称:recolnat-diff,代码行数:14,代码来源:UtilityService.php

示例10: resetDoctrineSchema

 /**
  * @param string|null $managerName
  *
  * @throws \Doctrine\ORM\Tools\ToolsException
  */
 public function resetDoctrineSchema($managerName = null)
 {
     $manager = $this->doctrine->getManager($managerName);
     $metadata = $manager->getMetadataFactory()->getAllMetadata();
     $schemaTool = new SchemaTool($manager);
     $schemaTool->dropSchema($metadata);
     $schemaTool->createSchema($metadata);
 }
开发者ID:sgomez,项目名称:rad-fixtures-load,代码行数:13,代码来源:ResetSchemaProcessor.php

示例11: validate

 /**
  * @param object $entity
  * @param Constraint $constraint
  */
 public function validate($entity, Constraint $constraint)
 {
     if (!is_array($constraint->fields) && !is_string($constraint->fields)) {
         throw new UnexpectedTypeException($constraint->fields, 'array');
     }
     $fields = (array) $constraint->fields;
     if (0 === count($fields)) {
         throw new ConstraintDefinitionException('At least one field has to be specified.');
     }
     if ($constraint->em) {
         $em = $this->registry->getManager($constraint->em);
     } else {
         $em = $this->registry->getManagerForClass(get_class($entity));
     }
     $className = $this->context->getCurrentClass();
     $class = $em->getClassMetadata($className);
     /* @var $class \Doctrine\Common\Persistence\Mapping\ClassMetadata */
     $criteria = array();
     foreach ($fields as $fieldName) {
         if (!$class->hasField($fieldName) && !$class->hasAssociation($fieldName)) {
             throw new ConstraintDefinitionException("Only field names mapped by Doctrine can be validated for uniqueness.");
         }
         $criteria[$fieldName] = $class->reflFields[$fieldName]->getValue($entity);
         if (null === $criteria[$fieldName]) {
             return;
         }
         if ($class->hasAssociation($fieldName)) {
             /* Ensure the Proxy is initialized before using reflection to
              * read its identifiers. This is necessary because the wrapped
              * getter methods in the Proxy are being bypassed.
              */
             $em->initializeObject($criteria[$fieldName]);
             $relatedClass = $em->getClassMetadata($class->getAssociationTargetClass($fieldName));
             $relatedId = $relatedClass->getIdentifierValues($criteria[$fieldName]);
             if (count($relatedId) > 1) {
                 throw new ConstraintDefinitionException("Associated entities are not allowed to have more than one identifier field to be " . "part of a unique constraint in: " . $class->getName() . "#" . $fieldName);
             }
             $criteria[$fieldName] = array_pop($relatedId);
         }
     }
     $repository = $em->getRepository($className);
     $result = $repository->findBy($criteria);
     /* If the result is a MongoCursor, it must be advanced to the first
      * element. Rewinding should have no ill effect if $result is another
      * iterator implementation.
      */
     if ($result instanceof \Iterator) {
         $result->rewind();
     }
     /* If no entity matched the query criteria or a single entity matched,
      * which is the same as the entity being validated, the criteria is
      * unique.
      */
     if (0 === count($result) || 1 === count($result) && $entity === ($result instanceof \Iterator ? $result->current() : current($result))) {
         return;
     }
     $this->context->addViolationAtSubPath($fields[0], $constraint->message, array(), $criteria[$fields[0]]);
 }
开发者ID:inscriptionweb,项目名称:Website,代码行数:62,代码来源:UniqueEntityValidator.php

示例12: beforeSuite

 /**
  * {@inheritdoc}
  */
 public function beforeSuite(SuiteEvent $suiteEvent, array $options)
 {
     foreach ($options['managers'] as $managerName) {
         /** @var DocumentManager $manager */
         $manager = $this->managerRegistry->getManager($managerName);
         $purger = new MongoDBPurger($manager);
         $purger->purge();
     }
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:12,代码来源:MongoDBPurgerListener.php

示例13: isApplicableOnEmailCampaign

 /**
  * Checks the object is an instance of a given class.
  *
  * @param EmailCampaign $entity
  * @return bool
  */
 public function isApplicableOnEmailCampaign($entity)
 {
     if ($entity instanceof EmailCampaign && $entity->getTransport() == MailChimpTransport::NAME) {
         $campaign = $this->registry->getManager()->getRepository('OroCRMMailChimpBundle:Campaign')->findOneBy(['emailCampaign' => $entity]);
         return (bool) $campaign;
     } else {
         return false;
     }
 }
开发者ID:aculvi,项目名称:OroCRMMailChimpBundle,代码行数:15,代码来源:EmailCampaignPlaceholderFilter.php

示例14: removeAll

 protected function removeAll()
 {
     /** @var EntityManager $em */
     $em = $this->doctrine->getManager();
     foreach ($this->doctrine->getRepository('NetNexusTimesheetBundle:Workitem')->findAll() as $wi) {
         $em->remove($wi);
     }
     $em->flush();
 }
开发者ID:netnexus,项目名称:timesheet,代码行数:9,代码来源:ImportCommand.php

示例15: getIdentifierValues

 /**
  * @param object $value
  *
  * @throws \InvalidArgumentException When $value is not a Doctrine object
  *
  * @return array
  */
 protected function getIdentifierValues($value)
 {
     if (!is_object($value)) {
         throw new \InvalidArgumentException('Only Doctrine objects can be serialized');
     }
     $class = get_class($value);
     $metadata = $this->doctrine->getManager()->getClassMetadata($class);
     return $metadata->getIdentifierValues($value);
 }
开发者ID:treehouselabs,项目名称:queue,代码行数:16,代码来源:DoctrineSerializer.php


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