]> git.mxchange.org Git - friendica.git/blob - src/Factory/Api/Mastodon/Field.php
Merge pull request #8222 from annando/ap-gnusocial
[friendica.git] / src / Factory / Api / Mastodon / Field.php
1 <?php
2
3 namespace Friendica\Factory\Api\Mastodon;
4
5 use Friendica\BaseFactory;
6 use Friendica\Collection\Api\Mastodon\Fields;
7 use Friendica\Collection\ProfileFields;
8 use Friendica\Content\Text\BBCode;
9 use Friendica\Model\ProfileField;
10 use Friendica\Network\HTTPException;
11
12 class Field extends BaseFactory
13 {
14         /**
15          * @param ProfileField $profileField
16          * @return \Friendica\Api\Entity\Mastodon\Field
17          * @throws HTTPException\InternalServerErrorException
18          */
19         public function createFromProfileField(ProfileField $profileField)
20         {
21                 return new \Friendica\Api\Entity\Mastodon\Field($profileField->label, BBCode::convert($profileField->value, false, 9));
22         }
23
24         /**
25          * @param ProfileFields $profileFields
26          * @return Fields
27          * @throws HTTPException\InternalServerErrorException
28          */
29         public function createFromProfileFields(ProfileFields $profileFields)
30         {
31                 $fields = [];
32
33                 foreach ($profileFields as $profileField) {
34                         $fields[] = $this->createFromProfileField($profileField);
35                 }
36
37                 return new Fields($fields);
38         }
39 }