Commit e45b6a7c authored by Emiliano Balbuena's avatar Emiliano Balbuena

(feat): Featured content entities

1 merge request!292WIP: (feat): Minds Pro (development branch) - Release 2
Pipeline #75261511 failed with stages
in 4 minutes and 12 seconds
......@@ -12,6 +12,7 @@ use Minds\Core\EntitiesBuilder;
use Minds\Core\Pro\Settings;
use Minds\Entities\Object\Carousel;
use Minds\Entities\User;
use Minds\Helpers\Text;
class HydrateSettingsDelegate
{
......@@ -74,6 +75,28 @@ class HydrateSettingsDelegate
error_log($e);
}
try {
if ($user->getPinnedPosts()) {
$pinnedPosts = $this->entitiesBuilder->get(['guids' => Text::buildArray($user->getPinnedPosts())]);
uasort($pinnedPosts, function ($a, $b) {
if (!$a || !$b) {
return 0;
}
return ($a->time_created < $b->time_created) ? 1 : -1;
});
$featuredContent = Text::buildArray(array_values(array_filter(array_map(function ($pinnedPost) {
return $pinnedPost->entity_guid ?: $pinnedPost->guid ?: null;
}, $pinnedPosts))));
$settings->setFeaturedContent($featuredContent);
}
} catch (\Exception $e) {
error_log($e);
}
return $settings;
}
}
......@@ -33,13 +33,15 @@ use Minds\Traits\MagicAttributes;
* @method array getFooterLinks()
* @method Settings setFooterLinks(array $footerLinks)
* @method array getTagList()
* @method Settings setTagList(array $footerLinks)
* @method Settings setTagList(array $tagList)
* @method string getScheme()
* @method Settings setScheme(string $scheme)
* @method string getBackgroundImage()
* @method Settings setBackgroundImage(string $backgroundImage)
* @method string getLogoImage()
* @method Settings setLogoImage(string $logoImage)
* @method array getFeaturedContent()
* @method Settings setFeaturedContent(array $featuredContent)
*/
class Settings implements JsonSerializable
{
......@@ -93,6 +95,9 @@ class Settings implements JsonSerializable
/** @var string */
protected $scheme;
/** @var array */
protected $featuredContent = [];
/**
* @return array
*/
......@@ -116,6 +121,7 @@ class Settings implements JsonSerializable
'logo_guid' => (string) $this->logoGuid,
'background_image' => $this->backgroundImage,
'logo_image' => $this->logoImage,
'featured_content' => $this->featuredContent,
'scheme' => $this->scheme,
'styles' => $this->buildStyles(),
];
......
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