本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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));
}
示例5: loadUserByUsername
public function loadUserByUsername($username)
{
if (!$username) {
return null;
}
return $this->_doctrine->getRepository('SiteBundle:User')->findOneBy(['username' => $username]);
}
示例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');
}
示例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;
}
示例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);
}
示例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');
}
示例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;
}
示例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));
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}