mirror of
https://github.com/friendica/friendica
synced 2025-04-27 11:10:12 +00:00
Add DDD classes for Mastodon\Field entity
This commit is contained in:
parent
5670c19d5c
commit
07a4bb73fa
4 changed files with 76 additions and 1 deletions
39
src/Factory/Api/Mastodon/Field.php
Normal file
39
src/Factory/Api/Mastodon/Field.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
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\Api\Entity\Mastodon\Field
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function createFromProfileField(ProfileField $profileField)
|
||||
{
|
||||
return new \Friendica\Api\Entity\Mastodon\Field($profileField->label, BBCode::convert($profileField->value, false, 9));
|
||||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue