本文整理汇总了PHP中Symfony\Bridge\Doctrine\ManagerRegistry::getRepository方法的典型用法代码示例。如果您正苦于以下问题:PHP ManagerRegistry::getRepository方法的具体用法?PHP ManagerRegistry::getRepository怎么用?PHP ManagerRegistry::getRepository使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bridge\Doctrine\ManagerRegistry
的用法示例。
在下文中一共展示了ManagerRegistry::getRepository方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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];
}
示例3: 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;
}
示例4: 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;
}
示例5: 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);
}
}
}
示例6: __invoke
/**
* Retrieves a collection of resources.
*
* @param Request $request
*
* @return array|\Dunglas\ApiBundle\Model\PaginatorInterface|\Traversable
*
* @throws RuntimeException|RootNodeNotFoundException
*/
public function __invoke(Request $request)
{
list($resourceType) = $this->extractAttributes($request);
/**
* @var ResourceInterface $resourceType
*/
$repository = $this->manager->getRepository($resourceType->getEntityClass());
/**
* @var $repository AbstractTreeRepository
*/
$rootNodes = $repository->getRootNodes();
if (count($rootNodes) == 0) {
throw new RootNodeNotFoundException();
}
$rootNode = reset($rootNodes);
return $rootNode;
}
示例7: sync
/**
* Syncs email bodies
*
* @param int $maxExecTimeInMin
* @param int $batchSize
*/
public function sync($maxExecTimeInMin = -1, $batchSize = 10)
{
$repo = $this->doctrine->getRepository('OroEmailBundle:Email');
$maxExecTimeout = $maxExecTimeInMin > 0 ? new \DateInterval('PT' . $maxExecTimeInMin . 'M') : false;
$startTime = new \DateTime('now', new \DateTimeZone('UTC'));
while (true) {
if ($maxExecTimeout !== false) {
$date = new \DateTime('now', new \DateTimeZone('UTC'));
if ($date->sub($maxExecTimeout) >= $startTime) {
$this->logger->notice('Exit because allocated time frame elapsed.');
break;
}
}
$emails = $repo->getEmailsWithoutBody($batchSize);
if (count($emails) === 0) {
$this->logger->notice('All emails was processed');
break;
}
$batchStartTime = new \DateTime('now', new \DateTimeZone('UTC'));
/** @var Email $email */
foreach ($emails as $email) {
try {
$this->syncOneEmailBody($email);
$this->logger->notice(sprintf('The "%s" (ID: %d) email body was synced.', $email->getSubject(), $email->getId()));
} catch (\Exception $e) {
// in case of exception, we should save state that email body was synced.
$this->getManager()->persist($email);
continue;
}
}
$this->getManager()->flush();
$this->getManager()->clear();
$currentTime = new \DateTime('now', new \DateTimeZone('UTC'));
$diff = $currentTime->diff($batchStartTime);
$this->logger->info(sprintf('Batch save time: %s.', $diff->format('%i minutes %s seconds')));
}
}
示例8: getJobInstanceRepository
/**
* @return EntityRepository
*/
protected function getJobInstanceRepository()
{
return $this->managerRegistry->getRepository('AkeneoBatchBundle:JobInstance');
}
示例9: getPageRepository
/**
* Get the Pages Repository
*
* @return PageRepository
*/
private function getPageRepository()
{
return $this->em->getRepository('KRSolutionsKRCMSBundle:Page');
}
示例10: getDislikes
/**
* Renvoie le nombre de "j'aime pas"
* @param Post $post
* @return int
*/
public function getDislikes(Post $post)
{
$repository = $this->doctrine->getRepository('LpdwBundle:PostLike');
return $repository->getCountLikes($post, -1);
}