本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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');
}
示例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);
}
示例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);
}
示例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;
}));
}
示例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;
});
}
示例10: configureCatalogContext
/**
* Define locale and scope in CatalogContext
*/
protected function configureCatalogContext()
{
$this->catalogContext->setLocaleCode($this->userContext->getCurrentLocaleCode());
$this->catalogContext->setScopeCode($this->userContext->getUserChannelCode());
}
示例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]);
}
示例12: getChoiceUrlParams
/**
* @return array
*/
protected function getChoiceUrlParams()
{
return ['class' => $this->groupClass, 'dataLocale' => $this->userContext->getCurrentLocaleCode(), 'collectionId' => null];
}
示例13: getChoices
/**
* Get choices
*
* @return array
*/
public function getChoices()
{
return $this->repository->getChoices(['localeCode' => $this->userContext->getCurrentLocaleCode()]);
}
示例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]]);
}
示例15: getChoiceUrlParams
/**
* @param AttributeInterface $attribute
*
* @return array
*/
protected function getChoiceUrlParams(AttributeInterface $attribute)
{
return ['class' => $this->optionRepoClass, 'dataLocale' => $this->userContext->getCurrentLocaleCode(), 'collectionId' => $attribute->getId()];
}