本文整理汇总了PHP中Doctrine\Bundle\DoctrineBundle\Registry类的典型用法代码示例。如果您正苦于以下问题:PHP Registry类的具体用法?PHP Registry怎么用?PHP Registry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Registry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param Registry $manager,
* @param RequestStack $requestStack,
* @param ObjectManager $persistence
*
* @InjectParams({
* "manager" = @Inject("doctrine"),
* "requestStack" = @Inject("request_stack"),
* "persistence" = @Inject("claroline.persistence.object_manager")
* })
*/
public function __construct(Registry $manager, RequestStack $requestStack, ObjectManager $persistence)
{
$this->manager = $persistence;
$this->request = $requestStack->getCurrentRequest();
$this->content = $manager->getRepository('ClarolineCoreBundle:Content');
$this->translations = $manager->getRepository('ClarolineCoreBundle:ContentTranslation');
}
示例2: __construct
public function __construct(Registry $doctrine, ContainerInterface $container, VersionService $versionService, CronLoggerService $cronLoggerService)
{
$this->entityManager = $doctrine->getManager();
$this->setContainer($container);
$this->versionService = $versionService;
$this->cronLoggerService = $cronLoggerService;
}
示例3: __construct
/**
* @param Registry $em
* @param string $class
*/
public function __construct(Registry $em, $class, Request $request)
{
$this->em = $em->getManagerForClass($class);
$this->class = $class;
$this->repository = $em->getRepository($class);
$this->request = $request;
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$this->institutionMediaService = $this->getContainer()->get('services.institution.media');
$this->fileSystem = $this->institutionMediaService->getFilesystem();
$this->logoSizes = $this->institutionMediaService->getSizesByType(InstitutionMediaService::LOGO_TYPE_IMAGE);
$this->featuredMediaSizes = $this->institutionMediaService->getSizesByType(InstitutionMediaService::FEATURED_TYPE_IMAGE);
$this->gallerySizes = $this->institutionMediaService->getSizesByType(InstitutionMediaService::GALLERY_TYPE_IMAGE);
// loop through all institutions
$this->doctrine = $this->getContainer()->get('doctrine');
$institutions = $this->doctrine->getRepository('InstitutionBundle:Institution')->findAll();
foreach ($institutions as $_institution) {
$this->output->writeln('Migrating images of institution #' . $_institution->getId());
$this->output->write(" ");
// migrate logo
$this->migrateLogo($_institution);
$this->output->write(" ");
// migrate banner
$this->migrateFeaturedMedia($_institution);
$this->output->write(" ");
// migrate gallery
$this->migrateGallery($_institution);
$this->output->write(" ");
// migrate clinic logos
foreach ($_institution->getInstitutionMedicalCenters() as $imc) {
$this->migrateClinicLogo($imc);
$this->output->write(" ");
}
$this->output->writeln('All Done.');
}
$this->output->writeln('END OF SCRIPT');
}
示例5: onSuccess
/**
* @param GridView $entity
*/
protected function onSuccess(GridView $entity)
{
$this->fixFilters($entity);
$om = $this->registry->getManagerForClass('OroDataGridBundle:GridView');
$om->persist($entity);
$om->flush();
}
示例6: getEntityManager
/**
* @return EntityManager
*/
private function getEntityManager()
{
if (!$this->doctrine) {
$this->doctrine = $this->container->get('doctrine');
}
return $this->doctrine->getManager($this->entityManagerName);
}
示例7: getAccessTokenWithCheckingExpiration
/**
* @param UserEmailOrigin $origin
*
* @return string
*/
public function getAccessTokenWithCheckingExpiration(UserEmailOrigin $origin)
{
$expiresAt = $origin->getAccessTokenExpiresAt();
$utcTimeZone = new \DateTimeZone('UTC');
$now = new \DateTime('now', $utcTimeZone);
$token = $origin->getAccessToken();
//if token had been expired, the new one must be generated and saved to DB
if ($now > $expiresAt && $this->configManager->get('oro_imap.enable_google_imap')) {
$parameters = ['refresh_token' => $origin->getRefreshToken(), 'grant_type' => 'refresh_token'];
$attemptNumber = 0;
do {
$attemptNumber++;
$response = $this->doHttpRequest($parameters);
if (!empty($response['access_token'])) {
$token = $response['access_token'];
$origin->setAccessToken($token);
$newExpireDate = new \DateTime('+' . $response['expires_in'] . ' seconds', $utcTimeZone);
$origin->setAccessTokenExpiresAt($newExpireDate);
$this->doctrine->getManager()->persist($origin);
$this->doctrine->getManager()->flush();
}
} while ($attemptNumber <= self::RETRY_TIMES && empty($response['access_token']));
}
return $token;
}
示例8: renderDay
/**
* @param $date
* @param $item
* @param $precision
* @param $route_new
* @param $route_show
*/
public function renderDay($date, $item, $project, $precision, $route_new, $route_show)
{
$start = new \DateTime($date);
$end = (new \DateTime($date))->modify('+1 day');
$bookings = $this->doctrine->getRepository($this->entity)->createQueryBuilder('b')->select('b')->where('b.start <= :start and b.end >= :end')->orwhere('b.end >= :start and b.end <= :end')->orwhere('b.start >= :start and b.start <= :end')->andWhere('b.item = :item')->orderBy('b.start', 'ASC')->setParameters(array('start' => $start, 'end' => $end, 'item' => $item))->getQuery()->getResult();
return $this->environment->render('SladBookingBundle:Calendar:day.html.twig', array('date' => new \DateTime($date), 'item' => $item, 'project' => $project, 'bookings' => $bookings, 'precision' => $precision, 'route_new' => $route_new, 'route_show' => $route_show));
}
示例9: process
/**
* @param LineItem $lineItem
*
* @return bool
*/
public function process(LineItem $lineItem)
{
if (in_array($this->request->getMethod(), ['POST', 'PUT'], true)) {
/** @var EntityManagerInterface $manager */
$manager = $this->registry->getManagerForClass('OroB2BShoppingListBundle:LineItem');
$manager->beginTransaction();
// handle case for new shopping list creation
$formName = $this->form->getName();
$formData = $this->request->request->get($formName, []);
if (empty($formData['shoppingList']) && !empty($formData['shoppingListLabel'])) {
$shoppingList = $this->shoppingListManager->createCurrent($formData['shoppingListLabel']);
$formData['shoppingList'] = $shoppingList->getId();
$this->request->request->set($formName, $formData);
}
$this->form->submit($this->request);
if ($this->form->isValid()) {
/** @var LineItemRepository $lineItemRepository */
$lineItemRepository = $manager->getRepository('OroB2BShoppingListBundle:LineItem');
$existingLineItem = $lineItemRepository->findDuplicate($lineItem);
if ($existingLineItem) {
$this->updateExistingLineItem($lineItem, $existingLineItem);
} else {
$manager->persist($lineItem);
}
$manager->flush();
$manager->commit();
return true;
} else {
$manager->rollBack();
}
}
return false;
}
示例10: loadUserByUsername
public function loadUserByUsername($username)
{
if (!$username) {
return null;
}
return $this->_doctrine->getRepository('SiteBundle:User')->findOneBy(['username' => $username]);
}
示例11: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->doctrine = $this->getContainer()->get('doctrine');
// get all cities
$qb = $this->doctrine->getManager()->createQueryBuilder();
$qb->select('ct')->from('HelperBundle:City', 'ct')->where('ct.geoCityId IS NOT NULL')->orderBy('ct.id', 'ASC');
$cities = $qb->getQuery()->getResult();
$connection = $this->doctrine->getConnection();
foreach ($cities as $city) {
$output->write('Updating data of old city #' . $city->getId());
$sql = "SELECT cg_gct.* FROM `chromedia_global`.`geo_cities` cg_gct WHERE cg_gct.`id` = ?";
$statement = $connection->prepare($sql);
$statement->bindValue(1, $city->getGeoCityId());
$statement->execute();
$globalCityData = $statement->fetch();
if ($globalCityData) {
$updateSql = "UPDATE `cities` SET `id` = :geoCityId, `name` = :geoCityName, `slug` = :geoCitySlug WHERE `old_id` = :oldId";
$updateStatement = $connection->prepare($updateSql);
$updateStatement->bindValue('geoCityId', $globalCityData['id']);
$updateStatement->bindValue('geoCityName', $globalCityData['name']);
$updateStatement->bindValue('geoCitySlug', $globalCityData['slug']);
$updateStatement->bindValue('oldId', $city->getOldId());
$updateStatement->execute();
$output->writeln(' OK');
} else {
$output->writeln(' Not found');
}
}
}
示例12: dispatch
/**
* Dispatch a covoit using database alerts.
* Find matching alerts, create notifications and send them.
*
* @param Covoit $covoit
*/
public function dispatch(Covoit $covoit)
{
/** @var EntityManager $em */
$em = $this->doctrine->getManager();
/*
* We find all the alerts and try to match these objects with the covoit. However, as the number of result could
* be big, we use some simple conditions to limit results : he startCity, the endCity and the price. Matching
* date is difficult directly in SQL as the condition depends of which fields are filled.
*/
/** @var CovoitAlert[] $alerts */
$alerts = $em->createQueryBuilder()->select('a, s, e, u')->from('EtuModuleCovoitBundle:CovoitAlert', 'a')->leftJoin('a.startCity', 's')->leftJoin('a.endCity', 'e')->leftJoin('a.user', 'u')->where('a.startCity = :startCiy OR a.startCity IS NULL')->andWhere('a.endCity = :endCity OR a.endCity IS NULL')->andWhere('a.priceMax <= :price OR a.priceMax IS NULL')->setParameters(['startCiy' => $covoit->getStartCity()->getId(), 'endCity' => $covoit->getEndCity()->getId(), 'price' => $covoit->getPrice()])->getQuery()->getResult();
// Notifications - Send only one notification per user, even if covoit match several alerts
$notifications = [];
foreach ($alerts as $alert) {
if ($this->match($alert, $covoit)) {
$notif = $this->createNotification($covoit);
$notif->setEntityId($alert->getId());
$notif->setAuthorId($covoit->getAuthor()->getId());
$notifications[$alert->getUser()->getId()] = $notif;
}
}
// Send the notifications
foreach ($notifications as $notification) {
$this->sender->send($notification);
}
}
示例13: unsubscribe
/**
* @param string $entityType
* @param integer $entityId
* @param User $user
* @return bool
*/
public function unsubscribe(User $user, $entityType, $entityId)
{
/** @var $em EntityManager */
$em = $this->doctrine->getManager();
$em->createQueryBuilder()->delete('EtuCoreBundle:Subscription', 's')->andWhere('s.entityId = :entityId')->andWhere('s.entityType = :entityType')->andWhere('s.user = :user')->setParameter('entityType', $entityType)->setParameter('entityId', $entityId)->setParameter('user', $user->getId())->getQuery()->execute();
return true;
}
示例14: __construct
public function __construct(ContainerInterface $container, UrlGeneratorInterface $router, SecurityContext $securityContext, Doctrine $doctrine)
{
$this->router = $router;
$this->securityContext = $securityContext;
$this->em = $doctrine->getManager();
$this->container = $container;
}
示例15: contentBlock
/**
* @param string $blockName
* @param array $options
* @param string $default
* @return string
*/
public function contentBlock($blockName, $options = array(), $default = null)
{
$em = $this->doctrine->getManager();
$repository = $em->getRepository('GlavwebContentBlockBundle:ContentBlock');
$contentBlock = $repository->findOneByName($blockName);
$tag = isset($options['tag']) ? $options['tag'] : 'div';
$attr = isset($options['attr']) ? $options['attr'] : array();
if (isset($options['class'])) {
$attr['class'] = $options['class'];
}
if (isset($options['href'])) {
$attr['href'] = $options['href'];
}
if (!$contentBlock) {
$contentBlock = new ContentBlock();
$contentBlock->setName($blockName);
$contentBlock->setBody($default ? $default : $blockName);
$em->persist($contentBlock);
$em->flush();
}
$contentEditable = '';
$dataBlockName = '';
$isEditable = $this->request && $this->request->get('contenteditable') && $this->securityContext->isGranted('ROLE_ADMIN');
if ($isEditable) {
$contentEditable = ' contenteditable="true"';
$dataBlockName = ' data-block-name="' . $blockName . '"';
$attr['class'] = isset($attr['class']) ? $attr['class'] . ' js-content-block' : 'js-content-block';
}
$attrParts = array();
foreach ($attr as $attrName => $value) {
$attrParts[] = sprintf('%s="%s"', $attrName, $value);
}
return '<' . $tag . ' ' . implode(' ', $attrParts) . ' ' . $contentEditable . $dataBlockName . '>' . $contentBlock->getBody() . '</' . $tag . '>';
}