feat: add $links property to User resources
This commit is contained in:
@@ -12,11 +12,13 @@ use App\Dto\UserSignupDto;
|
||||
use App\Entity\User\User;
|
||||
use App\Entity\User\UserType;
|
||||
use App\Filter\OrderedLikeFilter;
|
||||
use App\Library\Link;
|
||||
use App\Mapping\Transformer\UserDisplayNameMapTransformer;
|
||||
use App\State\ApiResourceStateProvider;
|
||||
use App\State\User\UserSignupProcessor;
|
||||
use App\State\User\UserStateProcessor;
|
||||
use AutoMapper\Attribute\MapFrom;
|
||||
use AutoMapper\Attribute\MapTo;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
@@ -125,4 +127,20 @@ class UserApiResource
|
||||
*/
|
||||
#[API\ApiProperty(writable: false)]
|
||||
public bool $active;
|
||||
|
||||
/**
|
||||
* A list of URLs provided by the User.\
|
||||
* e.g: social profiles, personal website.
|
||||
*
|
||||
* @var Link[]
|
||||
*/
|
||||
#[API\ApiProperty(writable: false)]
|
||||
#[MapTo(User::class, transformer: [self::class, 'parseLinks'])]
|
||||
#[MapFrom(User::class, transformer: [self::class, 'parseLinks'])]
|
||||
public array $links = [];
|
||||
|
||||
public static function parseLinks(array $values)
|
||||
{
|
||||
return \array_map(fn($value) => Link::tryFrom($value), $values);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Entity\DateUpdatedTrait;
|
||||
use App\Entity\DedupedTrait;
|
||||
use App\Entity\MigratedTrait;
|
||||
use App\Entity\Project\Project;
|
||||
use App\Library\Link;
|
||||
use App\Mapping\Provider\EntityMapProvider;
|
||||
use App\Repository\User\UserRepository;
|
||||
use AutoMapper\Attribute\MapProvider;
|
||||
@@ -113,6 +114,15 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface, Account
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $avatar = null;
|
||||
|
||||
/**
|
||||
* A list of URLs provided by the User.\
|
||||
* e.g: social profiles, personal website.
|
||||
*
|
||||
* @var Link[]
|
||||
*/
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?array $links = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->accounting = Accounting::of($this);
|
||||
@@ -371,4 +381,19 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface, Account
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLinks(): ?array
|
||||
{
|
||||
return $this->links;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Link[] $links
|
||||
*/
|
||||
public function setLinks(?array $links): static
|
||||
{
|
||||
$this->links = $links;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user