/** * @param array $data * @return PropertyGroup */ public function createPropertyGroup($data) { $group = new PropertyGroup(); $group->setId($data['id']); $group->setName($data['name']); $group->setFilterable($data['filterable']); $me = $this; $options = array_map(function ($temp) use($me) { return $me->createPropertyOption($temp); }, $data['options']); $group->setOptions($options); $group->addAttributes($this->createAttributes($data['attributes'])); return $group; }
/** * @param array $data * @return Struct\Property\Group */ public function hydrateGroup(array $data) { $group = new Struct\Property\Group(); $translation = $this->getTranslation($data, '__propertyGroup_translation', '__propertyGroup_translation_fallback', ['optionName' => '__propertyGroup_name']); $data = array_merge($data, $translation); $group->setId((int) $data['__propertyGroup_id']); $group->setName($data['__propertyGroup_name']); $group->setFilterable((bool) $data['__propertyGroup_filterable']); return $group; }
/** * @param StoreFrontBundle\Struct\Property\Group $group * @return array */ public function convertPropertyGroupStruct(StoreFrontBundle\Struct\Property\Group $group) { $data = array('id' => $group->getId(), 'name' => $group->getName(), 'isFilterable' => $group->isFilterable(), 'options' => array(), 'attributes' => array()); foreach ($group->getAttributes() as $key => $attribute) { $data['attributes'][$key] = $attribute->toArray(); } foreach ($group->getOptions() as $option) { $data['options'][] = $this->convertPropertyOptionStruct($option); } return $data; }