Commit d990fea9 authored by Emiliano Balbuena's avatar Emiliano Balbuena

(feat): Logo GUID settings and hydration

1 merge request!281WIP: (feat): Minds Pro
Pipeline #74218345 passed with stages
in 11 minutes and 15 seconds
......@@ -35,7 +35,15 @@ class thumbnail extends Core\page implements Interfaces\page
$contents = $thumbnail->read();
}
header('Content-type: image/jpeg');
try {
$finfo = new \finfo(FILEINFO_MIME);
$contentType = $finfo->buffer($contents) ?: 'image/jpeg';
} catch (\Exception $e) {
error_log($e);
$contentType = 'image/jpeg';
}
header('Content-type: ' . $contentType);
header('Expires: ' . date('r', strtotime('today + 6 months')), true);
header('Pragma: public');
header('Cache-Control: public');
......
......@@ -43,11 +43,15 @@ class HydrateSettingsDelegate
public function onGet(User $user, Settings $settings)
{
try {
$avatarUrl = $user->getIconURL('large');
$logoImage = $settings->getLogoGuid() ? sprintf(
'%sfs/v1/thumbnail/%s/master',
$this->config->get('cdn_url'),
$settings->getLogoGuid()
) : $user->getIconURL('large');
if ($avatarUrl) {
if ($logoImage) {
$settings
->setLogoImage($avatarUrl);
->setLogoImage($logoImage);
}
} catch (\Exception $e) {
error_log($e);
......
......@@ -196,6 +196,13 @@ class Manager
->setPlainBackgroundColor($values['plain_background_color']);
}
if (isset($values['logo_guid'])) {
// TODO: Validate!
$settings
->setLogoGuid($values['logo_guid']);
}
if (isset($values['footer_text'])) {
// TODO: Validate!
......
......@@ -93,6 +93,7 @@ class Repository
->setTextColor($data['text_color'] ?? '')
->setPrimaryColor($data['primary_color'] ?? '')
->setPlainBackgroundColor($data['plain_background_color'] ?? '')
->setLogoGuid($data['logo_guid'] ?? '')
->setFooterText($data['footer_text'] ?? '')
->setFooterLinks($data['footer_links'] ?? []);
......@@ -134,6 +135,7 @@ class Repository
'text_color' => $settings->getTextColor(),
'primary_color' => $settings->getPrimaryColor(),
'plain_background_color' => $settings->getPlainBackgroundColor(),
'logo_guid' => $settings->getLogoGuid(),
'footer_text' => $settings->getFooterText(),
'footer_links' => $settings->getFooterLinks(),
]),
......
......@@ -26,6 +26,8 @@ use Minds\Traits\MagicAttributes;
* @method Settings setPrimaryColor(string $primaryColor)
* @method string getPlainBackgroundColor()
* @method Settings setPlainBackgroundColor(string $plainBackgroundColor)
* @method int|string getLogoGuid()
* @method Settings setLogoGuid(int|string $logoGuid)
* @method string getFooterText()
* @method Settings setFooterText(string $footerText)
* @method array getFooterLinks()
......@@ -66,6 +68,9 @@ class Settings implements JsonSerializable
/** @var string */
protected $plainBackgroundColor;
/** @var int */
protected $logoGuid;
/** @var string */
protected $backgroundImage;
......@@ -93,6 +98,7 @@ class Settings implements JsonSerializable
'plain_background_color' => $this->plainBackgroundColor ?: static::DEFAULT_PLAIN_BACKGROUND_COLOR,
'footer_text' => $this->footerText,
'footer_links' => $this->footerLinks,
'logo_guid' => (string) $this->logoGuid,
'background_image' => $this->backgroundImage,
'logo_image' => $this->logoImage,
'styles' => [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment