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


PHP UserContext::getCurrentLocaleCode方法代码示例

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


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

示例1: findTranslatedLabels

 /**
  * {@inheritdoc}
  */
 public function findTranslatedLabels(array $options = [])
 {
     $query = $this->createQueryBuilder('f')->select('f.id')->addSelect('COALESCE(NULLIF(ft.label, \'\'), CONCAT(\'[\', f.code, \']\')) as label')->leftJoin('f.translations', 'ft', 'WITH', 'ft.locale = :locale_code')->orderBy('label')->setParameter('locale_code', $this->userContext->getCurrentLocaleCode())->getQuery();
     $choices = [];
     foreach ($query->getArrayResult() as $family) {
         $choices[$family['id']] = $family['label'];
     }
     return $choices;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:12,代码来源:FamilyRepository.php

示例2: findTranslatedLabels

 /**
  * {@inheritdoc}
  */
 public function findTranslatedLabels(array $options = [])
 {
     $queryBuilder = $this->createQueryBuilder('g')->select('g.id')->addSelect('COALESCE(NULLIF(t.label, \'\'), CONCAT(\'[\', g.code, \']\')) as label')->leftJoin('g.translations', 't', 'WITH', 't.locale = :locale')->setParameter('locale', $this->userContext->getCurrentLocaleCode())->orderBy('t.label');
     if (isset($options['type'])) {
         $queryBuilder->andWhere('g.type = :type')->setParameter('type', $options['type']);
     }
     $choices = [];
     foreach ($queryBuilder->getQuery()->getArrayResult() as $code) {
         $choices[$code['id']] = $code['label'];
     }
     return $choices;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:15,代码来源:GroupTypeRepository.php

示例3: getLocale

 /**
  * Get datalocale from parent's parameters, fallback on request parameters to deal with the mass edit case
  *
  * @param array $queryParameters
  *
  * @return string
  */
 protected function getLocale($queryParameters)
 {
     $dataLocale = null;
     if (isset($queryParameters['dataLocale'])) {
         $dataLocale = $queryParameters['dataLocale'];
     }
     if (null === $dataLocale) {
         $dataLocale = $this->request->get('dataLocale', null);
     }
     if (null === $dataLocale) {
         $dataLocale = $this->userContext->getCurrentLocaleCode();
     }
     return $dataLocale;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:21,代码来源:AddParametersToProductGridListener.php

示例4: findTranslatedLabels

 /**
  * {@inheritdoc}
  */
 public function findTranslatedLabels(array $options = [])
 {
     $queryBuilder = $this->createQueryBuilder('a')->select('a.code')->addSelect('COALESCE(NULLIF(at.label, \'\'), CONCAT(\'[\', a.code, \']\')) as attribute_label')->addSelect('COALESCE(NULLIF(gt.label, \'\'), CONCAT(\'[\', g.code, \']\')) as group_label')->leftJoin('a.translations', 'at', 'WITH', 'at.locale = :locale_code')->leftJoin('a.group', 'g')->leftJoin('g.translations', 'gt', 'WITH', 'gt.locale = :locale_code')->orderBy('g.sortOrder, a.sortOrder')->setParameter('locale_code', $this->userContext->getCurrentLocaleCode());
     if (isset($options['excluded_attribute_ids']) && !empty($options['excluded_attribute_ids'])) {
         $queryBuilder->andWhere($queryBuilder->expr()->notIn('a.id', $options['excluded_attribute_ids']));
     }
     if (isset($options['useable_as_grid_filter'])) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('a.useableAsGridFilter', $options['useable_as_grid_filter']));
     }
     $choices = [];
     foreach ($queryBuilder->getQuery()->getArrayResult() as $attribute) {
         $choices[$attribute['group_label']][$attribute['code']] = $attribute['attribute_label'];
     }
     return $choices;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:18,代码来源:AttributeRepository.php

示例5: let

 function let(UserContext $userContext, EntityManager $em, ClassMetadata $classMetadata)
 {
     $classMetadata->name = 'group_type';
     $userContext->getCurrentLocaleCode()->willReturn('en_US');
     $em->getClassMetadata('groupTypeClass')->willReturn($classMetadata);
     $this->beConstructedWith($userContext, $em, 'groupTypeClass');
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:7,代码来源:GroupTypeRepositorySpec.php

示例6: let

 function let(SecurityContextInterface $securityContext, AddLocaleListener $listener, CatalogContext $catalogContext, UserContext $userContext, GetResponseEvent $event)
 {
     $securityContext->getToken()->willReturn(true);
     $event->getRequestType()->willReturn(HttpKernel::MASTER_REQUEST);
     $userContext->getCurrentLocaleCode()->willReturn('de_DE');
     $userContext->getUserChannelCode()->willReturn('schmetterling');
     $this->beConstructedWith($securityContext, $listener, $catalogContext, $userContext);
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:8,代码来源:UserContextListenerSpec.php

示例7: let

 function let(UserContext $userContext, EntityManager $em, ClassMetadata $classMetadata, EventManager $eventManager, TreeListener $treeListener, Nested $strategy)
 {
     $classMetadata->name = 'category';
     $userContext->getCurrentLocaleCode()->willReturn('en_US');
     $em->getEventManager()->willReturn($eventManager);
     $eventManager->getListeners()->willReturn([[$treeListener]]);
     $treeListener->getStrategy(Argument::cetera())->willReturn($strategy);
     $treeListener->getConfiguration(Argument::cetera())->willReturn(['parent' => 'parent', 'left' => 'left']);
     $this->beConstructedWith($userContext, $em, $classMetadata);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:10,代码来源:CategoryRepositorySpec.php

示例8: setDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(array('class'));
     $resolver->setOptional(array('locale', 'url'));
     $resolver->setDefaults(array('multiple' => false, 'transformer_options' => array(), 'collection_id' => null, 'route' => 'pim_ui_ajaxentity_list', 'route_parameters' => array(), 'data_class' => null, 'error_bubbling' => false, 'minimum_input_length' => 0));
     $resolver->setNormalizers(array('locale' => function (Options $options, $value) {
         if (!$value) {
             $value = $this->userContext->getCurrentLocaleCode();
         }
         return $value;
     }, 'url' => function (Options $options, $value) {
         if (!$value) {
             $parameters = $this->getRouteParameters($options);
             $value = $this->router->generate($options['route'], $parameters);
         }
         return $value;
     }));
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:21,代码来源:AjaxEntityType.php

示例9: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setRequired(['class']);
     $resolver->setDefined(['locale', 'url']);
     $resolver->setDefaults(['multiple' => false, 'transformer_options' => [], 'collection_id' => null, 'route' => 'pim_ui_ajaxentity_list', 'route_parameters' => [], 'data_class' => null, 'error_bubbling' => false, 'minimum_input_length' => 0, 'locale' => null, 'url' => null, 'is_creatable' => false]);
     $resolver->setNormalizer('locale', function (Options $options, $value) {
         if (!$value) {
             $value = $this->userContext->getCurrentLocaleCode();
         }
         return $value;
     })->setNormalizer('url', function (Options $options, $value) {
         if (!$value) {
             $parameters = $this->getRouteParameters($options);
             $value = $this->router->generate($options['route'], $parameters);
         }
         return $value;
     });
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:21,代码来源:AjaxEntityType.php

示例10: configureCatalogContext

 /**
  * Define locale and scope in CatalogContext
  */
 protected function configureCatalogContext()
 {
     $this->catalogContext->setLocaleCode($this->userContext->getCurrentLocaleCode());
     $this->catalogContext->setScopeCode($this->userContext->getUserChannelCode());
 }
开发者ID:SamirBoulil,项目名称:pim-community-dev,代码行数:8,代码来源:UserContextListener.php

示例11: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('attributes', 'light_entity', ['repository' => $this->attributeRepository, 'repository_options' => ['excluded_attribute_ids' => $options['attributes'], 'locale_code' => $this->userContext->getCurrentLocaleCode()], 'multiple' => true, 'expanded' => false]);
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:7,代码来源:AvailableAttributesType.php

示例12: getChoiceUrlParams

 /**
  * @return array
  */
 protected function getChoiceUrlParams()
 {
     return ['class' => $this->groupClass, 'dataLocale' => $this->userContext->getCurrentLocaleCode(), 'collectionId' => null];
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:7,代码来源:GroupsFilter.php

示例13: getChoices

 /**
  * Get choices
  *
  * @return array
  */
 public function getChoices()
 {
     return $this->repository->getChoices(['localeCode' => $this->userContext->getCurrentLocaleCode()]);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:9,代码来源:FamilyManager.php

示例14: getFormOptions

 /**
  * {@inheritdoc}
  */
 protected function getFormOptions()
 {
     return array_merge(parent::getFormOptions(), ['choice_url' => 'pim_ui_ajaxentity_list', 'choice_url_params' => ['class' => $this->groupClass, 'dataLocale' => $this->userContext->getCurrentLocaleCode(), 'collectionId' => null]]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:7,代码来源:GroupsFilter.php

示例15: getChoiceUrlParams

 /**
  * @param AttributeInterface $attribute
  *
  * @return array
  */
 protected function getChoiceUrlParams(AttributeInterface $attribute)
 {
     return ['class' => $this->optionRepoClass, 'dataLocale' => $this->userContext->getCurrentLocaleCode(), 'collectionId' => $attribute->getId()];
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:9,代码来源:ChoiceFilter.php


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