Use Status object in User object

This commit is contained in:
Art4 2024-11-28 08:04:53 +00:00
parent 0b58562a4e
commit ec5d3e55c7
2 changed files with 5 additions and 6 deletions

View file

@ -57,7 +57,7 @@ class User extends BaseFactory
['author-id' => $publicContact['id'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_PARENT], 'private' => [Item::PUBLIC, Item::UNLISTED]], ['author-id' => $publicContact['id'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_PARENT], 'private' => [Item::PUBLIC, Item::UNLISTED]],
['order' => ['uri-id' => true]]); ['order' => ['uri-id' => true]]);
if (!empty($post['uri-id'])) { if (!empty($post['uri-id'])) {
$status = $this->status->createFromUriId($post['uri-id'], $uid)->toArray(); $status = $this->status->createFromUriId($post['uri-id'], $uid);
} }
} }

View file

@ -117,12 +117,11 @@ class User extends BaseDataTransferObject
* @param array $publicContact Full contact table record with uid = 0 * @param array $publicContact Full contact table record with uid = 0
* @param array $apcontact Optional full apcontact table record * @param array $apcontact Optional full apcontact table record
* @param array $userContact Optional full contact table record with uid != 0 * @param array $userContact Optional full contact table record with uid != 0
* @param array $status
* @param bool $include_user_entities Whether to add the entities property * @param bool $include_user_entities Whether to add the entities property
* *
* @throws InternalServerErrorException * @throws InternalServerErrorException
*/ */
public function __construct(array $publicContact, array $apcontact = [], array $userContact = [], ?array $status = null, bool $include_user_entities = true) public function __construct(array $publicContact, array $apcontact = [], array $userContact = [], ?Status $status = null, bool $include_user_entities = true)
{ {
$uid = $userContact['uid'] ?? 0; $uid = $userContact['uid'] ?? 0;
@ -156,10 +155,10 @@ class User extends BaseDataTransferObject
$this->default_profile = false; $this->default_profile = false;
$this->default_profile_image = false; $this->default_profile_image = false;
if (is_array($status)) { if ($status === null) {
$this->status = $status;
} else {
unset($this->status); unset($this->status);
} else {
$this->status = $status->toArray();
} }
// Unused optional fields // Unused optional fields