. * */ namespace Friendica\Factory\Api\Mastodon; use Friendica\BaseFactory; use Friendica\Collection\Api\Mastodon\Fields; use Friendica\Collection\ProfileFields; use Friendica\Content\Text\BBCode; use Friendica\Model\ProfileField; use Friendica\Network\HTTPException; class Field extends BaseFactory { /** * @param ProfileField $profileField * @return \Friendica\Object\Api\Mastodon\Field * @throws HTTPException\InternalServerErrorException */ public function createFromProfileField(ProfileField $profileField) { return new \Friendica\Object\Api\Mastodon\Field($profileField->label, BBCode::convert($profileField->value, false, BBCode::ACTIVITYPUB)); } /** * @param ProfileFields $profileFields * @return Fields * @throws HTTPException\InternalServerErrorException */ public function createFromProfileFields(ProfileFields $profileFields) { $fields = []; foreach ($profileFields as $profileField) { $fields[] = $this->createFromProfileField($profileField); } return new Fields($fields); } }