Refactoring Json Color
Change-Id: I06efe306a5486e1da20f0e3f5fc186249bea8e7d Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
c62ccb28e3
commit
da14571558
@ -20,7 +20,7 @@ class PresentationCategoryGroupSerializer extends SilverStripeSerializer
|
||||
{
|
||||
protected static $array_mappings = [
|
||||
'Name' => 'name:json_string',
|
||||
'Color' => 'color:json_string',
|
||||
'Color' => 'color:json_color',
|
||||
'Description' => 'description:json_string',
|
||||
'ClassName' => 'class_name:json_string',
|
||||
'SummitId' => 'summit_id:json_int',
|
||||
@ -39,14 +39,6 @@ class PresentationCategoryGroupSerializer extends SilverStripeSerializer
|
||||
$track_group = $this->object;
|
||||
if(!$track_group instanceof PresentationCategoryGroup) return $values;
|
||||
|
||||
$color = isset($values['color']) ? $values['color']:'';
|
||||
if(empty($color))
|
||||
$color = 'f0f0ee';
|
||||
if (strpos($color,'#') === false) {
|
||||
$color = '#'.$color;
|
||||
}
|
||||
$values['color'] = $color;
|
||||
|
||||
$categories = [];
|
||||
|
||||
foreach($track_group->getCategories() as $c)
|
||||
|
@ -33,7 +33,7 @@ final class PresentationCategorySerializer extends SilverStripeSerializer
|
||||
'VotingVisible' => 'voting_visible:json_boolean',
|
||||
'ChairVisible' => 'chair_visible:json_boolean',
|
||||
'SummitId' => 'summit_id:json_int',
|
||||
'Color' => 'color:json_string',
|
||||
'Color' => 'color:json_color',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -53,15 +53,6 @@ final class PresentationCategorySerializer extends SilverStripeSerializer
|
||||
$extra_questions = [];
|
||||
$summit = $category->getSummit();
|
||||
|
||||
$color = isset($values['color']) ? $values['color']:'';
|
||||
if(empty($color))
|
||||
$color = 'f0f0ee';
|
||||
|
||||
if (strpos($color,'#') === false) {
|
||||
$color = '#'.$color;
|
||||
}
|
||||
$values['color'] = $color;
|
||||
|
||||
foreach ($category->getGroups() as $group) {
|
||||
$groups[] = intval($group->getId());
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class SummitEventTypeSerializer extends SilverStripeSerializer
|
||||
protected static $array_mappings = [
|
||||
'Type' => 'name:json_string',
|
||||
'ClassName' => 'class_name:json_string',
|
||||
'Color' => 'color:json_string',
|
||||
'Color' => 'color:json_color',
|
||||
'BlackoutTimes' => 'black_out_times:json_boolean',
|
||||
'UseSponsors' => 'use_sponsors:json_boolean',
|
||||
'AreSponsorsMandatory' => 'are_sponsors_mandatory:json_boolean',
|
||||
@ -46,13 +46,6 @@ class SummitEventTypeSerializer extends SilverStripeSerializer
|
||||
$event_type = $this->object;
|
||||
if (!$event_type instanceof SummitEventType) return [];
|
||||
$values = parent::serialize($expand, $fields, $relations, $params);
|
||||
$color = isset($values['color']) ? $values['color']:'';
|
||||
if(empty($color))
|
||||
$color = 'f0f0ee';
|
||||
if (strpos($color,'#') === false) {
|
||||
$color = '#'.$color;
|
||||
}
|
||||
$values['color'] = $color;
|
||||
|
||||
$summit_documents = [];
|
||||
foreach ($event_type->getSummitDocuments() as $document) {
|
||||
|
@ -21,7 +21,7 @@ class SummitTypeSerializer extends SilverStripeSerializer
|
||||
protected static $array_mappings = array
|
||||
(
|
||||
'Title' => 'name:json_string',
|
||||
'Color' => 'color:json_string',
|
||||
'Color' => 'color:json_color',
|
||||
'Type' => 'type:json_string',
|
||||
);
|
||||
|
||||
@ -35,13 +35,6 @@ class SummitTypeSerializer extends SilverStripeSerializer
|
||||
public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array() )
|
||||
{
|
||||
$values = parent::serialize($expand, $fields, $relations, $params);
|
||||
$color = isset($values['color']) ? $values['color']:'';
|
||||
if(empty($color))
|
||||
$color = 'f0f0ee';
|
||||
if (strpos($color,'#') === false) {
|
||||
$color = '#'.$color;
|
||||
}
|
||||
$values['color'] = $color;
|
||||
return $values;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user