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


PHP ManagerRegistry::getManagerForClass方法代码示例

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


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

示例1: finishView

 /**
  * {@inheritdoc}
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     /** @var ShoppingListRepository $shoppingListRepository */
     $shoppingListRepository = $currentShoppingList = $this->registry->getManagerForClass($this->shoppingListClass)->getRepository($this->shoppingListClass);
     $currentShoppingList = $shoppingListRepository->findCurrentForAccountUser($this->getAccountUser());
     $view->children['shoppingList']->vars['currentShoppingList'] = $currentShoppingList;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:10,代码来源:FrontendLineItemWidgetType.php

示例2: getClassMetadata

 /**
  * Returns a metadata for the given entity
  *
  * @param string $className
  * @return ClassMetadata
  */
 protected function getClassMetadata($className)
 {
     if (isset($this->classMetadataLocalCache[$className])) {
         return $this->classMetadataLocalCache[$className];
     }
     $classMetadata = $this->doctrine->getManagerForClass($className)->getClassMetadata($className);
     $this->classMetadataLocalCache[$className] = $classMetadata;
     return $classMetadata;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:15,代码来源:AbstractOrmQueryConverter.php

示例3: getFieldNameByColumnName

 /**
  * Gets an entity field name by entity table name and column name
  *
  * @param string $tableName
  * @param string $columnName
  * @return string|null
  */
 public function getFieldNameByColumnName($tableName, $columnName)
 {
     $className = $this->getEntityClassByTableName($tableName);
     if ($className) {
         $manager = $this->doctrine->getManagerForClass($className);
         if ($manager instanceof EntityManager) {
             return $manager->getClassMetadata($className)->getFieldName($columnName);
         }
     }
     return null;
 }
开发者ID:Maksold,项目名称:platform,代码行数:18,代码来源:EntityMetadataHelper.php

示例4: deserializeIdCollectionFromJson

 /**
  * @param JsonDeserializationVisitor $visitor
  * @param $data
  * @param array $type
  * @return ArrayCollection
  */
 public function deserializeIdCollectionFromJson(JsonDeserializationVisitor $visitor, $data, array $type)
 {
     $collection = new ArrayCollection();
     $class = $type['params'][0]['name'];
     /** @var \Doctrine\Common\Persistence\ObjectRepository $repository */
     $repository = $this->doctrine->getManagerForClass($class)->getRepository($class);
     foreach ($data as $key => $value) {
         $collection->add($repository->findOneBy(array('id' => $value)));
     }
     return $collection;
 }
开发者ID:stanlemon,项目名称:rest-bundle,代码行数:17,代码来源:IdCollectionHandler.php

示例5: getQueryBuilder

 /**
  * {@inheritdoc}
  */
 public function getQueryBuilder(Segment $segment)
 {
     $converter = new SegmentQueryConverter($this->manager, $this->virtualFieldProvider, $this->doctrine, $this->restrictionBuilder);
     if ($this->virtualRelationProvider) {
         $converter->setVirtualRelationProvider($this->virtualRelationProvider);
     }
     /** @var EntityManager  $em */
     $em = $this->doctrine->getManagerForClass($segment->getEntity());
     $qb = $converter->convert(new RestrictionSegmentProxy($segment, $em));
     return $qb;
 }
开发者ID:Maksold,项目名称:platform,代码行数:14,代码来源:DynamicSegmentQueryBuilder.php

示例6: getMarketingListItem

 /**
  * @param MarketingList $marketingList
  * @param int $entityId
  * @return MarketingListItem
  */
 public function getMarketingListItem(MarketingList $marketingList, $entityId)
 {
     $marketingListItemRepository = $this->registry->getRepository(self::MARKETING_LIST_ITEM_ENTITY);
     $marketingListItem = $marketingListItemRepository->findOneBy(['marketingList' => $marketingList, 'entityId' => $entityId]);
     if (!$marketingListItem) {
         $marketingListItem = new MarketingListItem();
         $marketingListItem->setMarketingList($marketingList)->setEntityId($entityId);
         $manager = $this->registry->getManagerForClass(self::MARKETING_LIST_ITEM_ENTITY);
         $manager->persist($marketingListItem);
     }
     return $marketingListItem;
 }
开发者ID:antrampa,项目名称:crm,代码行数:17,代码来源:MarketingListItemConnector.php

示例7: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $em = $this->registry->getManagerForClass($this->integrationEntityFQCN);
     $formFactory = $builder->getFormFactory();
     $data = $builder->create('data', 'hidden');
     $data->addViewTransformer(new ArrayToJsonTransformer());
     $identifier = $builder->create('identifier', 'hidden');
     $identifier->addViewTransformer(new EntityToIdTransformer($em, $this->integrationEntityFQCN));
     $builder->addViewTransformer(new DatasourceDataTransformer($formFactory));
     $builder->add($data);
     $builder->add($identifier);
     $builder->add('type', 'hidden', ['data' => $options['type']]);
     $builder->add('name', 'hidden');
 }
开发者ID:antrampa,项目名称:crm,代码行数:17,代码来源:ChannelDatasourceType.php

示例8: processExclusions

 /**
  * @param object $object
  * @param object|null $entity
  */
 protected function processExclusions($object, $entity)
 {
     $class = get_class($object);
     if (!$entity) {
         return;
     }
     $reflection = new \ReflectionClass($class);
     /** Backfill data that is ignored or read only from the serializer */
     $metadata = $this->metadataFactory->getMetadataForClass($class);
     foreach ($reflection->getProperties() as $property) {
         $name = $property->getName();
         if (!isset($metadata->propertyMetadata[$name]) || $metadata->propertyMetadata[$name]->readOnly) {
             $property->setAccessible(true);
             $property->setValue($object, $property->getValue($entity));
         }
     }
     $em = $this->doctrine->getManagerForClass($class);
     /** @var \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata */
     $metadata = $em->getMetadataFactory()->getMetadataFor($class);
     // Look for relationships, compare against preloaded entity
     foreach ($metadata->getAssociationNames() as $fieldName) {
         if ($metadata->isCollectionValuedAssociation($fieldName)) {
             $property = $reflection->getProperty($fieldName);
             $property->setAccessible(true);
             if ($property->getValue($object)) {
                 foreach ($property->getValue($object) as $i => $value) {
                     $v = $property->getValue($entity);
                     $this->processExclusions($value, $v[$i]);
                 }
             }
         }
     }
 }
开发者ID:stanlemon,项目名称:rest-bundle,代码行数:37,代码来源:Processor.php

示例9: getManagerForClass

 /**
  * Gets doctrine entity manager for the given class
  *
  * @param string $className
  *
  * @return EntityManager
  * @throws InvalidEntityException
  */
 protected function getManagerForClass($className)
 {
     $manager = null;
     try {
         $manager = $this->doctrine->getManagerForClass($className);
     } catch (\ReflectionException $ex) {
         throw new InvalidEntityException(sprintf('The "%s" entity was not found.', $className));
     }
     return $manager;
 }
开发者ID:sagikazarmark,项目名称:platform,代码行数:18,代码来源:EntityFieldProvider.php

示例10: preSubmit

 /**
  * @param FormEvent $event
  */
 public function preSubmit(FormEvent $event)
 {
     /** @var LineItem $lineItem */
     $lineItem = $event->getForm()->getData();
     $data = $event->getData();
     $product = $lineItem->getProduct();
     if (!$product instanceof Product && !empty($data['product'])) {
         /** @var ProductRepository $repository */
         $repository = $this->registry->getManagerForClass($this->productClass)->getRepository($this->productClass);
         /** @var Product $product */
         $product = $repository->find((int) $data['product']);
     }
     if (!$product || empty($data['unit']) || empty($data['quantity'])) {
         return;
     }
     $roundedQuantity = $this->lineItemManager->roundProductQuantity($product, $data['unit'], $data['quantity']);
     $data['quantity'] = $roundedQuantity;
     $event->setData($data);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:22,代码来源:LineItemSubscriber.php

示例11: it_should_have_doctrine_data_indexer

 /**
  * @param \Symfony\Bridge\Doctrine\ManagerRegistry $registry
  * @param \Doctrine\Common\Persistence\ObjectManager $om
  * @param \Doctrine\Common\Persistence\ObjectRepository $repository
  * @param \Doctrine\ORM\Mapping\ClassMetadata $metadata
  */
 public function it_should_have_doctrine_data_indexer($registry, $om, $repository, $metadata)
 {
     $registry->getManagerForClass('FSi/Bundle/DemoBundle/Entity/Entity')->willReturn($om);
     $om->getRepository('FSiDemoBundle:Entity')->willReturn($repository);
     $metadata->isMappedSuperclass = false;
     $metadata->rootEntityName = 'FSi/Bundle/DemoBundle/Entity/Entity';
     $om->getClassMetadata('FSi/Bundle/DemoBundle/Entity/Entity')->willReturn($metadata);
     $repository->getClassName()->willReturn('FSi/Bundle/DemoBundle/Entity/Entity');
     $this->setManagerRegistry($registry);
     $this->getDataIndexer()->shouldReturnAnInstanceOf('FSi\\Component\\DataIndexer\\DoctrineDataIndexer');
 }
开发者ID:kbedn,项目名称:admin-bundle,代码行数:17,代码来源:DeleteElementSpec.php

示例12: 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

示例13: getClassMetadata

 /**
  * @param string|object $class
  * @return ClassMetadata
  */
 protected function getClassMetadata($class)
 {
     if (is_object($class)) {
         $class = get_class($class);
     }
     if (!is_string($class)) {
         throw new \InvalidArgumentException("Argument must be either string or object, got " . gettype($class));
     }
     $objectManager = $this->managerRegistry->getManagerForClass($class);
     if (null === $objectManager) {
         throw new \RuntimeException("Could not find object manager for class '{$class}'");
     }
     return $objectManager->getClassMetadata($class);
 }
开发者ID:matthiasbayer,项目名称:json-api-bundle,代码行数:18,代码来源:JsonApiHandler.php

示例14: build

 /**
  * {inheritdoc}
  */
 public function build(Segment $segment)
 {
     $converter = new SegmentQueryConverter($this->manager, $this->virtualFieldProvider, $this->doctrine, $this->restrictionBuilder);
     $qb = $converter->convert(new RestrictionSegmentProxy($segment, $this->doctrine->getManagerForClass($segment->getEntity())));
     return $qb->getQuery();
 }
开发者ID:xamin123,项目名称:platform,代码行数:9,代码来源:DynamicSegmentQueryBuilder.php

示例15: isEntity

 /**
  * Check if given class is real entity class
  *
  * @param string $className
  * @return bool
  */
 public function isEntity($className)
 {
     return !is_null($this->doctrine->getManagerForClass($className));
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:10,代码来源:EntityClassResolver.php


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