details on Person

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/82/head
Maxence Lange 2018-11-29 16:39:55 -01:00 zatwierdzone przez Julius Härtl
rodzic 93b7973cbd
commit 54ce1b496a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4C614C6ED2CDE6DF
5 zmienionych plików z 80 dodań i 8 usunięć

Wyświetl plik

@ -380,6 +380,13 @@
<notnull>true</notnull>
</field>
<field>
<name>details</name>
<type>text</type>
<length>3000</length>
<notnull>false</notnull>
</field>
<field>
<name>creation</name>
<type>timestamp</type>

Wyświetl plik

@ -5,7 +5,7 @@
<name>Social</name>
<summary>🎉 Nextcloud becomes part of the federated social networks!</summary>
<description><![CDATA[test]]></description>
<version>0.0.52</version>
<version>0.0.53</version>
<licence>agpl</licence>
<author mail="maxence@artificial-owl.com">Maxence Lange</author>
<author mail="jus@bitgrid.net">Julius Härtl</author>

8
composer.lock wygenerowano
Wyświetl plik

@ -12,12 +12,12 @@
"source": {
"type": "git",
"url": "https://github.com/daita/my-small-php-tools.git",
"reference": "39ea0ce3f9442cb507c0bfaa4be36c3e90d6903e"
"reference": "36ea85a58ceb57a521c8f5a43effb4a7330e7b4c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/39ea0ce3f9442cb507c0bfaa4be36c3e90d6903e",
"reference": "39ea0ce3f9442cb507c0bfaa4be36c3e90d6903e",
"url": "https://api.github.com/repos/daita/my-small-php-tools/zipball/36ea85a58ceb57a521c8f5a43effb4a7330e7b4c",
"reference": "36ea85a58ceb57a521c8f5a43effb4a7330e7b4c",
"shasum": ""
},
"require": {
@ -40,7 +40,7 @@
}
],
"description": "My small PHP Tools",
"time": "2018-11-29T12:56:09+00:00"
"time": "2018-11-29T16:46:38+00:00"
}
],
"packages-dev": [],

Wyświetl plik

@ -85,6 +85,7 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
->setValue('summary', $qb->createNamedParameter($actor->getSummary()))
->setValue('public_key', $qb->createNamedParameter($actor->getPublicKey()))
->setValue('source', $qb->createNamedParameter($actor->getSource()))
->setValue('details', $qb->createNamedParameter(json_encode($actor->getDetails())))
->setValue(
'creation',
$qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE)

Wyświetl plik

@ -85,6 +85,10 @@ class Person extends ACore implements JsonSerializable {
/** @var string */
private $featured = '';
/** @var array */
private $details = [];
/**
* Person constructor.
*
@ -339,6 +343,61 @@ class Person extends ACore implements JsonSerializable {
}
/**
* @return array
*/
public function getDetails(): array {
return $this->details;
}
/**
* @param string $detail
* @param string $value
*
* @return Person
*/
public function addDetail(string $detail, string $value): Person {
$this->details[$detail] = $value;
return $this;
}
/**
* @param string $detail
* @param int $value
*
* @return Person
*/
public function addDetailInt(string $detail, int $value): Person {
$this->details[$detail] = $value;
return $this;
}
/**
* @param string $detail
* @param array $value
*
* @return Person
*/
public function addDetailArray(string $detail, array $value): Person {
$this->details[$detail] = $value;
return $this;
}
/**
* @param array $details
*
* @return Person
*/
public function setDetails(array $details): Person {
$this->details = $details;
return $this;
}
/**
* @param array $data
*
@ -390,6 +449,7 @@ class Person extends ACore implements JsonSerializable {
->setFollowing($this->get('following', $data, ''))
->setSharedInbox($this->get('shared_inbox', $data, ''))
->setFeatured($this->get('featured', $data, ''))
->setDetails($this->getArray('details', $data, []))
->setCreation($this->getInt('creation', $data, 0));
// if ($this->getPreferredUsername() === '') {
@ -402,7 +462,7 @@ class Person extends ACore implements JsonSerializable {
* @return array
*/
public function jsonSerialize(): array {
return array_merge(
$result = array_merge(
parent::jsonSerialize(),
[
'aliases' => [
@ -425,8 +485,12 @@ class Person extends ACore implements JsonSerializable {
]
]
);
if ($this->isCompleteDetails()) {
$result['details'] = $this->getDetails();
}
return $result;
}
}