Skip to content

Commit

Permalink
[TASK] Set PID for profile and its childs to PID of given user
Browse files Browse the repository at this point in the history
  • Loading branch information
dot3media authored and Riiiad committed Feb 13, 2024
1 parent 6ef1f50 commit 5cb7e41
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Classes/Profile/ProfileFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,22 @@ final class ProfileFactory extends AbstractProfileFactory
*/
protected function createProfileFromFrontendUser(array $frontendUserData): Profile
{
$pid = (int)$frontendUserData['pid'];

$profile = new Profile();
$profile->setPid($pid);
$profile->setTitle((string)($frontendUserData['title'] ?? ''));
$profile->setFirstName((string)($frontendUserData['first_name'] ?? ''));
$profile->setMiddleName((string)($frontendUserData['middle_name'] ?? ''));
$profile->setLastName((string)($frontendUserData['last_name'] ?? ''));
$profile->setWebsite((string)($frontendUserData['www'] ?? ''));

$contract = new Contract();
$contract->setPid($pid);
$profile->getContracts()->attach($contract);

$address = new Address();
$address->setPid($pid);
$address->setStreet((string)($frontendUserData['address'] ?? ''));
$address->setZip((string)($frontendUserData['zip'] ?? ''));
$address->setCity((string)($frontendUserData['city'] ?? ''));
Expand All @@ -43,18 +48,21 @@ protected function createProfileFromFrontendUser(array $frontendUserData): Profi

if (!empty($frontendUserData['email'])) {
$email = new Email();
$email->setPid($pid);
$email->setEmail((string)($frontendUserData['email']));
$contract->getEmailAddresses()->attach($email);
}

if (!empty($frontendUserData['telephone'])) {
$phoneNumber = new PhoneNumber();
$phoneNumber->setPid($pid);
$phoneNumber->setPhoneNumber((string)($frontendUserData['telephone']));
$phoneNumber->setType('phone');
$contract->getPhoneNumbers()->attach($phoneNumber);
}
if (!empty($frontendUserData['fax'])) {
$phoneNumber = new PhoneNumber();
$phoneNumber->setPid($pid);
$phoneNumber->setPhoneNumber((string)($frontendUserData['fax']));
$phoneNumber->setType('fax');
$contract->getPhoneNumbers()->attach($phoneNumber);
Expand Down

0 comments on commit 5cb7e41

Please sign in to comment.