Ejemplo n.º 1
0
 /**
  * @param array $data
  * @return array
  */
 public function createNewCustomer($data)
 {
     $customer = new CustomerEntity();
     $maxUserName = (int) $this->getNewUserName() + 1;
     $customer->setClientId($maxUserName);
     $customer->setUsername($maxUserName);
     $customer->setSalutation($data['salutation']);
     $customer->setEmail($data['email']);
     $customer->setFirstName($data['firstName']);
     $customer->setLastName($data['lastName']);
     $customer->setDomain($data['domain']);
     $encoder = $this->encoderFactory->getEncoder($customer);
     $password = $this->generateRandomString();
     $customer->setPassword($encoder->encodePassword($password, $customer->getSalt()));
     $customer->setIsActive(true);
     $customer->setDbServer($this->getDbServer());
     $customer->setDbUser($this->getDbUser());
     $customer->setDbName($this->getDbName($customer->getUsername()));
     $customer->setDbPassword($this->getDbPassword());
     if (!isset($data['plan'])) {
         $data['plan'] = 269;
     }
     $customer->setTariff($data['plan']);
     $this->addNewRole($customer);
     $this->addNewExtra($data, $customer);
     return array($customer, $password);
 }