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


PHP Registry::getRepository方法代码示例

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


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

示例1: getRepository

 /**
  * Get the repository from the registry
  * We have to do this here because the call to registry::getRepository
  * requires the database to be setup which is a problem for using managers in console commands
  *
  * @return EntityRepository
  */
 protected function getRepository()
 {
     if (!$this->repository) {
         $this->repository = $this->registry->getRepository($this->class);
     }
     return $this->repository;
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:14,代码来源:BaseManager.php

示例2: tryAddUser

 /**
  * @param Request $request
  *
  * @return bool|User
  */
 public function tryAddUser(Request $request)
 {
     $params = $request->request->all();
     if (!isset($params['user']['id'])) {
         return false;
     }
     $user = $this->_doctrine->getRepository('SiteBundle:User')->findOneBy(['vk' => $params['user']['id']]);
     if ($user) {
         return $user;
     }
     $user = new User();
     $user->setName($params['user']['first_name']);
     $user->setLastname($params['user']['last_name']);
     $user->setVk($params['user']['id']);
     $user->setPassword($this->_generatePassword($params['user']['id']));
     $user->setUsername($this->_generateUserName($params['user']['id']));
     $user->setRole($this->_defaultRole());
     $user->setPhone('');
     $user->setPhoto('');
     $user->setEmail('');
     $em = $this->_doctrine->getManager();
     $em->persist($user);
     $em->flush();
     return $user;
 }
开发者ID:pihterev,项目名称:plans,代码行数:30,代码来源:VkApiKeyAuthenticator.php

示例3: getRights

 /**
  * Read available User/Host requirements from database
  *
  * @return array
  */
 public function getRights()
 {
     /** @var UserHostRepository $repository */
     $repository = $this->doctrine->getRepository($this->bundleName . ':UserHost');
     $result = $repository->findAllSelect();
     return $result;
 }
开发者ID:homerjsimpson000,项目名称:CommandSchedulerBundle,代码行数:12,代码来源:RightsParser.php

示例4: 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));
 }
开发者ID:stephylee,项目名称:SladBookingBundle,代码行数:14,代码来源:CalendarExtension.php

示例5: loadUserByUsername

 public function loadUserByUsername($username)
 {
     if (!$username) {
         return null;
     }
     return $this->_doctrine->getRepository('SiteBundle:User')->findOneBy(['username' => $username]);
 }
开发者ID:pihterev,项目名称:plans,代码行数:7,代码来源:ApiKeyUserProvider.php

示例6: 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');
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:32,代码来源:MigrateInstitutionImagesCommand.php

示例7: getCode

 public function getCode($bannerType, $place = null, $referenceId = null)
 {
     $bannerRepository = $this->doctrine->getRepository('AciliaBannerBundle:Banner');
     $bannerTag = '';
     if ($place == null) {
         $place = $this->place;
     }
     // If Place is not defined, Ad can't be shown
     if (null === $place) {
         return $bannerTag;
     }
     if ($referenceId === false) {
         $referenceId = null;
     } elseif ($referenceId == null) {
         $referenceId = $this->referenceId;
     }
     $context = $this->getContext();
     // Get URL
     $currentUrl = $this->requestStack->getMasterRequest()->getPathInfo();
     // Get resource and context
     $event = new ResourceBannerEvent();
     $this->dispatcher->dispatch(ResourceBannerEvent::NAME, $event);
     if ($event->isAvailable()) {
         $resource = $event->getResource();
         // Overwrite ad context if required
         if ($event->getContext() != null) {
             $context = $event->getContext();
         }
         // Banner identifier key
         $key = 'Banner:' . $resource . ':' . $context . ':' . $place . ':' . $bannerType . ':' . $referenceId . ':' . sha1($currentUrl);
         if (isset($this->instances[$key])) {
             return $this->instances[$key];
         }
         $bannerTag = $this->memcache->get($key);
         if ($this->memcache->notFound()) {
             // Create Banner Tag
             $bannerTag = new BannerTag();
             $bannerTag->setResource($resource)->setBannerType($bannerType)->setPlace($place)->setContext($context)->setReferenceId($referenceId)->setCacheKey($key);
             if ($bannerRepository->isPageAvailable($bannerTag, $currentUrl, $this->getType('none'))) {
                 return '<!-- BANNER BEGIN - This page has it\'s Ads Disabled - BANNER END -->';
             }
             // Fill Banner Tag
             $bannerRepository->fillBannerTag($bannerTag, $currentUrl, $this->getType($bannerTag->getBannerType()));
             $fallbacks = $this->fallbacks;
             while ($bannerTag->isEmpty() && count($fallbacks) > 0) {
                 $fallback = array_slice($fallbacks, 0, 1);
                 array_shift($fallbacks);
                 $place = key($fallback);
                 $referenceId = $fallback[$place];
                 $bannerTag->setPlace($place)->setReferenceId($referenceId);
                 // Fill Banner Tag
                 $bannerRepository->fillBannerTag($bannerTag, $currentUrl, $this->getType($bannerTag->getBannerType()));
             }
             // Save on Memcache and internally
             $this->instances[$key] = $bannerTag;
             $this->memcache->set($key, $bannerTag, 60);
         }
     }
     return $bannerTag;
 }
开发者ID:aciliainternet,项目名称:BannerBundle,代码行数:60,代码来源:BannerService.php

示例8: reverseTransform

 /**
  * reverseTransform
  *
  * @param integer $idx
  *
  * @return \Erichard\DmsBundle\Entity\DocumentNode|null|object
  */
 public function reverseTransform($idx)
 {
     if (null === $idx) {
         return null;
     }
     return $this->registry->getRepository('Erichard\\DmsBundle\\Entity\\DocumentNode')->find($idx);
 }
开发者ID:DavidG04,项目名称:ErichardDmsBundle,代码行数:14,代码来源:NodeToIdTransformer.php

示例9: __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');
 }
开发者ID:claroline,项目名称:distribution,代码行数:18,代码来源:ContentManager.php

示例10: findCurrentItem

 /**
  * Looks for the object that corresponds to the selected 'id' of the current entity.
  *
  * @param array $entityConfig
  * @param mixed $itemId
  *
  * @return object The entity
  *
  * @throws EntityNotFoundException
  */
 private function findCurrentItem(array $entityConfig, $itemId)
 {
     if (null === ($entity = $this->doctrine->getRepository($entityConfig['class'])->find($itemId))) {
         throw new EntityNotFoundException(array('entity' => $entityConfig, 'entity_id' => $itemId));
     }
     return $entity;
 }
开发者ID:artggd,项目名称:EasyAdminBundle,代码行数:17,代码来源:RequestPostInitializeListener.php

示例11: loadNode

 /**
  * @param int         $nodeId
  * @param null|string $type
  *
  * @return NodeReferenceInterface
  */
 public function loadNode($nodeId, $type = null)
 {
     if (is_null($type)) {
         $node = $this->registry->getRepository('ClasticNodeBundle:Node')->find($nodeId);
         $type = $node->getType();
     }
     return $this->registry->getRepository($this->getEntityName($type))->findOneBy(array('node' => $nodeId));
 }
开发者ID:clastic,项目名称:clastic,代码行数:14,代码来源:NodeManager.php

示例12: canYouDoIt

 private function canYouDoIt(Comment $comment, User $user)
 {
     $commentOwner = $this->doctrine->getRepository('AppBundle:User')->findOneBy(array('email' => $comment->getAuthorEmail()));
     if (in_array("ROLE_ADMIN", $commentOwner->getRoles()) || $comment->getArticle()->getAuthorEmail() !== $user->getEmail()) {
         return false;
     }
     return true;
 }
开发者ID:KateSyrotchuk,项目名称:blog,代码行数:8,代码来源:CommentVoter.php

示例13: handle

 /**
  * @param RemoveDojoCommand $command
  */
 public function handle(RemoveDojoCommand $command)
 {
     $dojo = $this->doctrine->getRepository('CoderDojoWebsiteBundle:Dojo')->find($command->getId());
     $this->doctrine->remove($dojo);
     $this->doctrine->flush();
     $event = new DojoRemovedEvent($command->getId());
     $this->eventRecorder->record($event);
 }
开发者ID:CoderDojoNederland,项目名称:Website,代码行数:11,代码来源:RemoveDojoHandler.php

示例14: executeAction

 /**
  * @param mixed $context
  */
 protected function executeAction($context)
 {
     $settingsClass = $this->contextAccessor->getValue($context, $this->processType);
     $settingsClass = $this->processStorage->getProcess($settingsClass)->getSettingsEntityFQCN();
     $email = $this->contextAccessor->getValue($context, $this->email);
     $results = $this->doctrine->getRepository('OroEmailBundle:Mailbox')->findBySettingsClassAndEmail($settingsClass, $email);
     $this->contextAccessor->setValue($context, $this->attribute, $results);
 }
开发者ID:2ndkauboy,项目名称:platform,代码行数:11,代码来源:RequestMailboxes.php

示例15: get

 /**
  * Fetches the data associated to the given parser parameters.
  * 
  * @param string $function
  * @param string $parser
  * @param object $target
  * 
  * @return mixed
  * Returns the associated cache data or null if it not exists.
  */
 public function get($function, $parser, $target)
 {
     $cacheKey = $this->buildCacheKey($function, $parser, $target);
     $cacheEntry = $this->doctrine->getRepository('PHPSanitizer\\ProjectBundle\\Entity\\AnalysesParsersCache')->findOneBy(array('key' => $cacheKey));
     if ($cacheEntry === null) {
         return null;
     }
     return $cacheEntry->getData();
 }
开发者ID:breta-ionut,项目名称:php-sanitizer,代码行数:19,代码来源:AnalysesParsersCacheManager.php


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