/** * @param AttributeInterface $attribute * @param array $data */ protected function addAvailableLocales(AttributeInterface $attribute, $data) { if (strtolower($data['available_locales']) !== 'all') { $locales = explode(',', $data['available_locales']); foreach ($locales as $localeCode) { $locale = new Locale(); $locale->setCode($localeCode); $attribute->addAvailableLocale($locale); } } }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $bundle = new \ReflectionClass('Pim\\Bundle\\InstallerBundle\\PimInstallerBundle'); $locales = array_map('trim', file(sprintf('%s/Resources/config/locales', dirname($bundle->getFileName())))); foreach ($locales as $localeCode) { $locale = new Locale(); $locale->setCode($localeCode); $this->setReference(get_class($locale) . '.' . $localeCode, $locale); $this->validate($locale, $localeCode); $manager->persist($locale); } $manager->flush(); }
function it_doesnt_remove_value_when_the_attribute_is_locale_specific_and_current_locale_is_in_available_list(FormEvent $event, FormInterface $form, FormInterface $field, FormInterface $rootForm, ProductValueInterface $taxValue, AttributeInterface $taxAttribute) { $event->getForm()->willReturn($form); $event->getData()->willReturn(['tax' => $taxValue]); $taxValue->getAttribute()->willReturn($taxAttribute); $fr = new Locale(); $fr->setCode('fr_FR'); $en = new Locale(); $en->setCode('en_US'); $taxAttribute->isLocaleSpecific()->willReturn(true); $taxAttribute->getLocaleSpecificCodes()->willReturn(['fr_FR', 'en_US']); $form->remove('tax')->shouldNotBeCalled(); $this->preSetData($event); }
/** * Create a locale for testing * * @param string $code * * @return \Pim\Bundle\CatalogBundle\Tests\Unit\Entity\Locale */ protected function createLocale($code) { $locale = new Locale(); $locale->setCode($code); return $locale; }
/** * @return array */ protected function getLocales() { $localeEn = new Locale(); $localeEn->setCode('en_US'); $localeFr = new Locale(); $localeFr->setCode('fr_FR'); return array($localeEn, $localeFr); }
/** * Test for __toString method */ public function testToString() { $code = 'en_US'; $this->locale->setCode($code); $this->assertEquals($code, $this->locale->__toString()); }
/** * @param AttributeInterface $attribute * @param array $data */ protected function addAvailableLocales(AttributeInterface $attribute, $data) { foreach ($data['available_locales'] as $code) { $locale = new Locale(); $locale->setCode($code); $attribute->addAvailableLocale($locale); } }
/** * {@inheritDoc} */ public function setCode($code) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCode', array($code)); return parent::setCode($code); }