'Created User', 'message' => 'You have successfully created a new User' ]; } /** @var CreateUserProcessor */ private $createUserProcessor; /** @var CreateCompanyProcessor */ private $createCompanyProcessor; /** @var CreateContactProcessor */ private $createContactProcessor; /** @var AssignEmployeeProcessor */ private $assignEmployeeProcessor; /** @var AssignSegmentProcessor */ private $assignSegmentProcessor; /** @var AuthenticationProcessor */ private $authenticationProcessor; /** @var GenerateEmailVerificationAttemptProcessor */ private $generateEmailVerificationAttemptProcessor; /** * CreateCustomerLogic constructor. * @param CreateUserProcessor $createUserProcessor * @param CreateCompanyProcessor $createCompanyProcessor * @param CreateContactProcessor $createContactProcessor * @param AssignEmployeeProcessor $assignEmployeeProcessor * @param AssignSegmentProcessor $assignSegmentProcessor * @param AuthenticationProcessor $authenticationProcessor * @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor */ public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateContactProcessor $createContactProcessor, AssignEmployeeProcessor $assignEmployeeProcessor, AssignSegmentProcessor $assignSegmentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor) { $this->createUserProcessor = $createUserProcessor; $this->createCompanyProcessor = $createCompanyProcessor; $this->createContactProcessor = $createContactProcessor; $this->assignEmployeeProcessor = $assignEmployeeProcessor; $this->assignSegmentProcessor = $assignSegmentProcessor; $this->authenticationProcessor = $authenticationProcessor; $this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor; } /** * @param Request $request * @return JsonResponse * @throws \App\Classes\Exceptions\AccessForbiddenException * @throws \App\Classes\Exceptions\AccessUnauthorisedException * @throws \App\Classes\Exceptions\InternalServerErrorException * @throws \App\Classes\Exceptions\MalformedRequestException * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse { /** @var User $user */ $user = $this->createUserProcessor->execute($request, RoleTypes::USER, App::environment(['local']) ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION); /** @var Company $company */ $company = $this->createCompanyProcessor->execute($request, BusinessType::IMPORTER, $request->input('type') === CompanyType::COMPANY_BUSINESS ? CompanyType::COMPANY_BUSINESS : CompanyType::PERSONAL_BUSINESS, ApprovalStatus::PENDING_SUBMISSION); $this->createContactProcessor->execute($request, $company); $Object = new EmploymentObject($company, $user); $this->assignEmployeeProcessor->execute($Object); $this->assignSegmentProcessor->execute($company); // $this->generateEmailVerificationAttemptProcessor->execute($user); return $this->response($this->authenticationProcessor->execute($request)); } }