/** * @param array $data * @return Struct\ProductStream */ public function hydrate(array $data) { $productStream = new Struct\ProductStream(); $translation = $this->getTranslation($data, '__stream_translation', '__stream_translation_fallback', $this->translationProductStreamFields); $data = array_merge($data, $translation); if (isset($data['__stream_id'])) { $productStream->setId((int) $data['__stream_id']); } if (isset($data['__stream_name'])) { $productStream->setName($data['__stream_name']); } if (isset($data['__stream_description'])) { $productStream->setDescription($data['__stream_description']); } if (isset($data['__stream_type'])) { $productStream->setType((int) $data['__stream_type']); } return $productStream; }
/** * Converts the passed ProductStream struct to an array structure. * * @param StoreFrontBundle\Struct\ProductStream $productStream * @return array */ public function convertRelatedProductStreamStruct(StoreFrontBundle\Struct\ProductStream $productStream) { if (!$productStream instanceof StoreFrontBundle\Struct\ProductStream) { return array(); } return ['id' => $productStream->getId(), 'name' => $productStream->getName(), 'description' => $productStream->getDescription(), 'type' => $productStream->getType()]; }