/** * Returns active locales * * @return Locale[] */ public function getUserLocales() { if ($this->userLocales === null) { $this->userLocales = $this->localeManager->getActiveLocales(); } return $this->userLocales; }
/** * Create locales field * * @param FormBuilderInterface $builder * * @return ChannelType */ protected function addLocalesField(FormBuilderInterface $builder) { $builder->add('locales', 'entity', ['required' => true, 'multiple' => true, 'select2' => true, 'by_reference' => false, 'class' => 'Pim\\Bundle\\CatalogBundle\\Entity\\Locale', 'query_builder' => function (LocaleRepositoryInterface $repository) { return $repository->getLocalesQB(); }, 'preferred_choices' => $this->localeManager->getActiveLocales()]); return $this; }
/** * Get cached active locales * * @return array */ protected function getActiveLocales() { if (!$this->activeLocales) { $this->activeLocales = $this->localeManager->getActiveLocales(); } return $this->activeLocales; }
/** * Edit attribute form * * @param Request $request * @param integer $id * * @Template("PimEnrichBundle:Attribute:form.html.twig") * @AclAncestor("pim_enrich_attribute_edit") * @return array */ public function editAction(Request $request, $id) { $attribute = $this->findAttributeOr404($id); if ($this->attributeHandler->process($attribute)) { $this->addFlash('success', 'flash.attribute.updated'); return $this->redirectToRoute('pim_enrich_attribute_edit', array('id' => $attribute->getId())); } return array('form' => $this->attributeForm->createView(), 'locales' => $this->localeManager->getActiveLocales(), 'disabledLocales' => $this->localeManager->getDisabledLocales(), 'measures' => $this->measuresConfig, 'created' => $this->versionManager->getOldestLogEntry($attribute), 'updated' => $this->versionManager->getNewestLogEntry($attribute)); }
/** * Return rows for available locales * * @param AbstractAttribute $attribute * * @return array */ protected function getLocaleRows(AbstractAttribute $attribute) { $locales = $this->localeManager->getActiveLocales(); $localeRows = array(); foreach ($locales as $locale) { $localeRows[] = array('attribute' => $attribute->getCode(), 'locale' => $locale->getCode(), 'scope' => null); } return $localeRows; }
function let(SecurityContextInterface $securityContext, LocaleManager $localeManager, ChannelManager $channelManager, CategoryManager $categoryManager, TokenInterface $token, User $user, LocaleInterface $en, LocaleInterface $fr, LocaleInterface $de, ChannelInterface $ecommerce, ChannelInterface $mobile, CategoryInterface $firstTree, CategoryInterface $secondTree) { $securityContext->getToken()->willReturn($token); $token->getUser()->willReturn($user); $en->getCode()->willReturn('en_US'); $fr->getCode()->willReturn('fr_FR'); $de->getCode()->willReturn('de_DE'); $en->isActivated()->willReturn(true); $fr->isActivated()->willReturn(true); $de->isActivated()->willReturn(true); $localeManager->getLocaleByCode('en_US')->willReturn($en); $localeManager->getLocaleByCode('fr_FR')->willReturn($fr); $localeManager->getLocaleByCode('de_DE')->willReturn($de); $localeManager->getActiveLocales()->willReturn([$en, $fr, $de]); $channelManager->getChannels()->willReturn([$mobile, $ecommerce]); $categoryManager->getTrees()->willReturn([$firstTree, $secondTree]); $this->beConstructedWith($securityContext, $localeManager, $channelManager, $categoryManager, 'en_US'); }
/** * Get active locales * * @return Locale[] */ public function getActiveLocales() { return $this->baseLocaleManager->getActiveLocales(); }