Move ProfileField from Model to Entity

This commit is contained in:
Philipp 2021-10-08 19:17:27 +02:00
parent 39a927f213
commit 1c0f92c382
No known key found for this signature in database
GPG Key ID: 24A7501396EB5432
4 changed files with 16 additions and 11 deletions

View File

@ -25,13 +25,14 @@ use Friendica\BaseFactory;
use Friendica\Collection\Api\Mastodon\Fields; use Friendica\Collection\Api\Mastodon\Fields;
use Friendica\Collection\ProfileFields; use Friendica\Collection\ProfileFields;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Model\ProfileField; use Friendica\Profile\ProfileField\Entity\ProfileField;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
class Field extends BaseFactory class Field extends BaseFactory
{ {
/** /**
* @param ProfileField $profileField * @param \Friendica\Profile\ProfileField\Entity\ProfileField $profileField
*
* @return \Friendica\Object\Api\Mastodon\Field * @return \Friendica\Object\Api\Mastodon\Field
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
*/ */

View File

@ -30,7 +30,7 @@ use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Model\ProfileField; use Friendica\Profile\ProfileField\Entity\ProfileField;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Module\BaseSettings; use Friendica\Module\BaseSettings;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;

View File

@ -19,7 +19,7 @@
* *
*/ */
namespace Friendica\Model; namespace Friendica\Profile\ProfileField\Entity;
use Friendica\BaseModel; use Friendica\BaseModel;
use Friendica\Database\Database; use Friendica\Database\Database;

View File

@ -36,7 +36,7 @@ class ProfileField extends BaseRepository
{ {
protected static $table_name = 'profile_field'; protected static $table_name = 'profile_field';
protected static $model_class = Model\ProfileField::class; protected static $model_class = \Friendica\Profile\ProfileField\Entity\ProfileField::class;
protected static $collection_class = Collection\ProfileFields::class; protected static $collection_class = Collection\ProfileFields::class;
@ -58,7 +58,8 @@ class ProfileField extends BaseRepository
/** /**
* @param array $data * @param array $data
* @return Model\ProfileField *
* @return \Friendica\Profile\ProfileField\Entity\ProfileField
*/ */
protected function create(array $data) protected function create(array $data)
{ {
@ -67,7 +68,8 @@ class ProfileField extends BaseRepository
/** /**
* @param array $condition * @param array $condition
* @return Model\ProfileField *
* @return \Friendica\Profile\ProfileField\Entity\ProfileField
* @throws \Friendica\Network\HTTPException\NotFoundException * @throws \Friendica\Network\HTTPException\NotFoundException
*/ */
public function selectFirst(array $condition) public function selectFirst(array $condition)
@ -138,7 +140,8 @@ class ProfileField extends BaseRepository
/** /**
* @param array $fields * @param array $fields
* @return Model\ProfileField|bool *
* @return \Friendica\Profile\ProfileField\Entity\ProfileField|bool
* @throws \Exception * @throws \Exception
*/ */
public function insert(array $fields) public function insert(array $fields)
@ -150,7 +153,8 @@ class ProfileField extends BaseRepository
} }
/** /**
* @param Model\ProfileField $model * @param \Friendica\Profile\ProfileField\Entity\ProfileField $model
*
* @return bool * @return bool
* @throws \Exception * @throws \Exception
*/ */
@ -202,7 +206,7 @@ class ProfileField extends BaseRepository
unset($profileFieldOrder['new']); unset($profileFieldOrder['new']);
// Prunes profile field whose label has been emptied // Prunes profile field whose label has been emptied
$profileFields = $profileFields->filter(function (Model\ProfileField $profileField) use (&$profileFieldInputs, &$profileFieldOrder) { $profileFields = $profileFields->filter(function (\Friendica\Profile\ProfileField\Entity\ProfileField $profileField) use (&$profileFieldInputs, &$profileFieldOrder) {
$keepModel = !isset($profileFieldInputs[$profileField->id]) || !empty($profileFieldInputs[$profileField->id]['label']); $keepModel = !isset($profileFieldInputs[$profileField->id]) || !empty($profileFieldInputs[$profileField->id]['label']);
if (!$keepModel) { if (!$keepModel) {
@ -218,7 +222,7 @@ class ProfileField extends BaseRepository
$profileFieldOrder = array_flip(array_keys($profileFieldOrder)); $profileFieldOrder = array_flip(array_keys($profileFieldOrder));
// Update existing profile fields from form values // Update existing profile fields from form values
$profileFields = $profileFields->map(function (Model\ProfileField $profileField) use ($uid, &$profileFieldInputs, &$profileFieldOrder) { $profileFields = $profileFields->map(function (\Friendica\Profile\ProfileField\Entity\ProfileField $profileField) use ($uid, &$profileFieldInputs, &$profileFieldOrder) {
if (isset($profileFieldInputs[$profileField->id]) && isset($profileFieldOrder[$profileField->id])) { if (isset($profileFieldInputs[$profileField->id]) && isset($profileFieldOrder[$profileField->id])) {
$psid = $this->permissionSet->selectOrCreate($this->permissionSetFactory->createFromString( $psid = $this->permissionSet->selectOrCreate($this->permissionSetFactory->createFromString(
$uid, $uid,