/**
  * @param AbstractAttribute $attribute
  * @param array             $data
  */
 protected function addAvailableLocales(AbstractAttribute $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);
         }
     }
 }
 /**
  * Test get/add/remove availableLocales property
  *
  * TODO : Add more tests
  */
 public function testGetAddRemoveAvailableLocales()
 {
     $this->assertNull($this->attribute->getAvailableLocales());
     // Change value and assert new
     $newLocale = new Locale();
     $this->attribute->addAvailableLocale($newLocale);
     $this->assertInstanceOf('Pim\\Bundle\\CatalogBundle\\Entity\\Locale', $this->attribute->getAvailableLocales()->first());
     $this->assertCount(1, $this->attribute->getAvailableLocales());
     $this->attribute->removeAvailableLocale($newLocale);
     $this->assertNull($this->attribute->getAvailableLocales());
 }
 /**
  * @param AbstractAttribute $attribute
  * @param array             $data
  */
 protected function addAvailableLocales(AbstractAttribute $attribute, $data)
 {
     foreach ($data['available_locales'] as $code) {
         $locale = new Locale();
         $locale->setCode($code);
         $attribute->addAvailableLocale($locale);
     }
 }