/**
  * Test getter/setter for label property
  */
 public function testGetSetLabel()
 {
     $this->assertEmpty($this->channel->getLabel());
     // change value and assert new
     $newLabel = 'E-Commerce';
     $this->assertEntity($this->channel->setLabel($newLabel));
     $this->assertEquals($newLabel, $this->channel->getLabel());
 }
 /**
  * Create a channel
  * @param string $code
  *
  * @return \Pim\Bundle\CatalogBundle\Entity\Channel
  */
 protected function createChannel($code)
 {
     $channel = new Channel();
     $channel->setCode($code);
     $channel->setLabel(ucfirst($code));
     return $channel;
 }
 /**
  * {@inheritdoc}
  *
  * @return Channel
  */
 protected function createEntity(array $data)
 {
     $channel = new Channel();
     $channel->setCode($data['code']);
     $channel->setLabel($data['label']);
     foreach ($data['currencies'] as $currencyCode) {
         $currency = $this->createCurrency($currencyCode);
         $channel->addCurrency($currency);
     }
     foreach ($data['locales'] as $localeCode) {
         $locale = $this->createLocale($localeCode);
         $channel->addLocale($locale);
     }
     $category = $this->createCategory($data['category']);
     $channel->setCategory($category);
     $channel->setConversionUnits(array('weight' => 'KILOGRAM', 'washing_temperature' => null));
     return $channel;
 }
Пример #4
0
 /**
  * @param array $data
  *
  * @return Channel
  */
 protected function createChannel($data)
 {
     if (is_string($data)) {
         $data = [['code' => $data]];
     }
     $data = array_merge(['label' => null, 'color' => null, 'currencies' => null, 'locales' => null, 'tree' => null], $data);
     $channel = new Channel();
     $channel->setCode($data['code']);
     $channel->setLabel($data['label']);
     if ($data['color']) {
         $channel->setColor($data['color']);
     }
     foreach ($this->listToArray($data['currencies']) as $currencyCode) {
         $channel->addCurrency($this->getCurrency($currencyCode));
     }
     foreach ($this->listToArray($data['locales']) as $localeCode) {
         $channel->addLocale($this->getLocale($localeCode));
     }
     if ($data['tree']) {
         $channel->setCategory($this->getCategory($data['tree']));
     }
     $this->validate($channel);
     $this->persist($channel);
 }
 /**
  * @param array $data
  *
  * @return Channel
  */
 protected function createChannel($data)
 {
     if (is_string($data)) {
         $data = [['code' => $data]];
     }
     $data = array_merge(['label' => null, 'currencies' => null, 'locales' => null, 'tree' => null], $data);
     $channel = new Channel();
     $channel->setCode($data['code']);
     $channel->setLabel($data['label']);
     foreach ($this->listToArray($data['currencies']) as $currencyCode) {
         $channel->addCurrency($this->getCurrency(['code' => explode(',', $currencyCode)]));
     }
     foreach ($this->listToArray($data['locales']) as $localeCode) {
         $channel->addLocale($this->getLocale(['code' => explode(',', $localeCode)]));
     }
     if ($data['tree']) {
         $channel->setCategory($this->getCategory($data['tree']));
     }
     $this->validate($channel);
     $this->getContainer()->get('pim_catalog.saver.channel')->save($channel);
 }
 /**
  * {@inheritDoc}
  */
 public function setLabel($label)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setLabel', array($label));
     return parent::setLabel($label);
 }