/** * Test getter/setter for category property */ public function testGetSetCategory() { $this->assertNull($this->channel->getCategory()); $expectedCategory = $this->createCategory('test-tree'); $this->assertEntity($this->channel->setCategory($expectedCategory)); $this->assertEquals($expectedCategory, $this->channel->getCategory()); }
/** * {@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; }
/** * @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 setCategory(\Pim\Bundle\CatalogBundle\Model\CategoryInterface $category) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCategory', array($category)); return parent::setCategory($category); }