Skip to content
Commits on Source (2)
......@@ -224,6 +224,28 @@ class Manager
->setFooterLinks(array_values($footerLinks));
}
if (isset($values['tag_list']) && is_array($values['tag_list'])) {
$tagList = array_map(function ($item) {
$tag = trim($item['tag'], "#\t\n\r");
$label = ($item['label'] ?? null) ?: "#{$item['tag']}";
return compact('label', 'tag');
}, array_filter($values['tag_list'], function ($item) {
return $item && $item['tag'];
}));
$settings
->setTagList(array_values($tagList));
}
if (isset($values['scheme'])) {
// TODO: Validate!
$settings
->setScheme($values['scheme']);
}
return $this->repository->update($settings);
}
}
......@@ -95,7 +95,10 @@ class Repository
->setPlainBackgroundColor($data['plain_background_color'] ?? '')
->setLogoGuid($data['logo_guid'] ?? '')
->setFooterText($data['footer_text'] ?? '')
->setFooterLinks($data['footer_links'] ?? []);
->setFooterLinks($data['footer_links'] ?? [])
->setTagList($data['tag_list'] ?? [])
->setScheme($data['scheme'] ?? '')
;
$response[] = $settings;
}
......@@ -138,6 +141,8 @@ class Repository
'logo_guid' => $settings->getLogoGuid(),
'footer_text' => $settings->getFooterText(),
'footer_links' => $settings->getFooterLinks(),
'tag_list' => $settings->getTagList(),
'scheme' => $settings->getScheme(),
]),
];
......
......@@ -32,6 +32,10 @@ use Minds\Traits\MagicAttributes;
* @method Settings setFooterText(string $footerText)
* @method array getFooterLinks()
* @method Settings setFooterLinks(array $footerLinks)
* @method array getTagList()
* @method Settings setTagList(array $footerLinks)
* @method string getScheme()
* @method Settings setScheme(string $scheme)
* @method string getBackgroundImage()
* @method Settings setBackgroundImage(string $backgroundImage)
* @method string getLogoImage()
......@@ -83,30 +87,51 @@ class Settings implements JsonSerializable
/** @var array */
protected $footerLinks = [];
/** @var array */
protected $tagList = [];
/** @var string */
protected $scheme;
/**
* @return array
*/
public function export()
{
$textColor = $this->textColor ?: static::DEFAULT_TEXT_COLOR;
$primaryColor = $this->primaryColor ?: static::DEFAULT_PRIMARY_COLOR;
$plainBackgroundColor = $this->plainBackgroundColor ?: static::DEFAULT_PLAIN_BACKGROUND_COLOR;
return [
'user_guid' => (string) $this->userGuid,
'domain' => $this->domain,
'title' => $this->title,
'headline' => $this->headline,
'text_color' => $this->textColor ?: static::DEFAULT_TEXT_COLOR,
'primary_color' => $this->primaryColor ?: static::DEFAULT_PRIMARY_COLOR,
'plain_background_color' => $this->plainBackgroundColor ?: static::DEFAULT_PLAIN_BACKGROUND_COLOR,
'text_color' => $textColor,
'primary_color' => $primaryColor,
'plain_background_color' => $plainBackgroundColor,
'footer_text' => $this->footerText,
'footer_links' => $this->footerLinks,
'tag_list' => $this->tagList,
'logo_guid' => (string) $this->logoGuid,
'background_image' => $this->backgroundImage,
'logo_image' => $this->logoImage,
'styles' => [
'text_color' => $this->textColor ?: static::DEFAULT_TEXT_COLOR,
'primary_color' => $this->primaryColor ?: static::DEFAULT_PRIMARY_COLOR,
'plain_background_color' => $this->plainBackgroundColor ?: static::DEFAULT_PLAIN_BACKGROUND_COLOR,
'transparent_background_color' => sprintf("%sa0", $this->plainBackgroundColor ?: static::DEFAULT_PLAIN_BACKGROUND_COLOR),
],
'scheme' => $this->scheme,
'styles' => $this->buildStyles(),
];
}
public function buildStyles()
{
$textColor = $this->textColor ?: static::DEFAULT_TEXT_COLOR;
$primaryColor = $this->primaryColor ?: static::DEFAULT_PRIMARY_COLOR;
$plainBackgroundColor = $this->plainBackgroundColor ?: static::DEFAULT_PLAIN_BACKGROUND_COLOR;
return [
'text_color' => $textColor,
'primary_color' => $primaryColor,
'plain_background_color' => $plainBackgroundColor,
'transparent_background_color' => sprintf("%sa0", $plainBackgroundColor),
];
}
......