'name:json_string', 'Color' => 'color:json_string', 'Description' => 'description:json_string', ); /** * @param null $expand * @param array $fields * @param array $relations * @param array $params * @return array */ public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array() ) { $values = parent::serialize($expand, $fields, $relations, $params); $group = $this->object; $color = isset($values['color']) ? $values['color']:''; if(empty($color)) $color = 'f0f0ee'; if (strpos($color,'#') === false) { $color = '#'.$color; } $values['color'] = $color; $categories = array(); foreach($group->getCategories() as $c) { if(!is_null($expand) && in_array('tracks', explode(',',$expand))){ $categories[] = SerializerRegistry::getInstance()->getSerializer($c)->serialize(); } else $categories[] = intval($c->getId()); } $values['tracks'] = $categories; return $values; } }