本文整理汇总了PHP中Symfony\Bridge\Doctrine\ManagerRegistry类的典型用法代码示例。如果您正苦于以下问题:PHP ManagerRegistry类的具体用法?PHP ManagerRegistry怎么用?PHP ManagerRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ManagerRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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;
}
示例2: 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');
}
示例3: 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;
}
示例4: setUpDoctrine
/**
*/
protected function setUpDoctrine()
{
static::bootKernel();
$this->container = static::$kernel->getContainer();
$this->doctrine = $this->createDoctrineRegistry();
$this->em = $this->doctrine->getManager();
$this->loader = new Loader();
}
示例5: 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;
}
示例6: execute
/**
* Executes a job with given payload
*
* @param array $payload
* @return mixed
*/
public function execute(array $payload)
{
list($entityClass, $entityId) = $payload;
$entity = $this->doctrine->getRepository($entityClass)->find($entityId);
if (null === $entity) {
return false;
}
return $this->exporter->cacheItem($entity);
}
示例7: 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;
}
示例8: 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;
}
示例9: getConfiguration
/**
* {@inheritdoc}
*/
public function getConfiguration($gridName)
{
if (empty($this->configuration[$gridName])) {
$id = intval(substr($gridName, strlen(Segment::GRID_PREFIX)));
$segmentRepository = $this->doctrine->getRepository('OroSegmentBundle:Segment');
$segment = $segmentRepository->find($id);
$this->builder->setGridName($gridName);
$this->builder->setSource($segment);
$this->configuration[$gridName] = $this->builder->getConfiguration();
}
return $this->configuration[$gridName];
}
示例10: 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;
}
示例11: getConfiguration
/**
* {@inheritdoc}
*/
public function getConfiguration($gridName)
{
if ($this->configuration === null) {
$id = intval(substr($gridName, strlen(Report::GRID_PREFIX)));
$repo = $this->doctrine->getRepository('OroReportBundle:Report');
$report = $repo->find($id);
$this->builder->setGridName($gridName);
$this->builder->setSource($report);
$this->configuration = $this->builder->getConfiguration();
}
return $this->configuration;
}
示例12: testGetDeleteMessageTextForDataGrid
public function testGetDeleteMessageTextForDataGrid()
{
$paymentTermId = 1;
$paymentTermRepository = $this->getMockBuilder('OroB2B\\Bundle\\PaymentBundle\\Entity\\Repository\\PaymentTermRepository')->disableOriginalConstructor()->getMock();
$paymentTermRepository->expects($this->once())->method('find')->with($paymentTermId)->willReturnCallback(function ($id) {
return new PaymentTermStub($id);
});
$om = $this->getMock('\\Doctrine\\Common\\Persistence\\ObjectManager');
$om->expects($this->once())->method('getRepository')->with($this->equalTo('OroB2BPaymentBundle:PaymentTerm'))->willReturn($paymentTermRepository);
$this->managerRegistry->expects($this->once())->method('getManagerForClass')->with($this->equalTo('OroB2BPaymentBundle:PaymentTerm'))->willReturn($om);
$message = $this->extension->getDeleteMessageTextForDataGrid($paymentTermId);
$this->assertDeleteMessage($message, $paymentTermId, 0, 0);
}
示例13: 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');
}
示例14: preSubmitData
/**
* @param FormEvent $event
*/
public function preSubmitData(FormEvent $event)
{
$data = $event->getData();
if (!isset($data['product'], $data['unit'], $data['quantity'])) {
return;
}
/** @var Product $product */
$product = $this->registry->getRepository($this->productClass)->find($data['product']);
if ($product) {
$unitPrecision = $product->getUnitPrecision($data['unit']);
if ($unitPrecision) {
$data['quantity'] = $this->roundingService->round($data['quantity'], $unitPrecision->getPrecision());
$event->setData($data);
}
}
}
示例15: 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();
}