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
rodzic 1bc3373b8f
commit f2a97772e7
5 zmienionych plików z 80 dodań i 8 usunięć

Wyświetl plik

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

Wyświetl plik

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

8
composer.lock wygenerowano
Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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