/** * Creates a user * * @param string $username * @param string $email * @param string $firstName * @param string $lastName * @param string $middleName * @param \DateTime $birthday * @return User */ private function createUser($username, $email, $firstName, $lastName, $middleName, $birthday) { /** @var $user User */ $user = $this->userManager->createUser(); $user->setEmail($email); $user->setUsername($username); $user->setFirstName($firstName); $user->setMiddlename($middleName); $user->setLastName($lastName); $user->setBirthday($birthday); $user->addRole($this->role[0]); $user->setOwner($this->businessUnit); return $user; }
/** * Load default administrator * * @param ObjectManager $manager * @throws \RuntimeException */ public function load(ObjectManager $manager) { $adminRole = $manager->getRepository('OroUserBundle:Role')->findOneBy(['role' => LoadRolesData::ROLE_ADMINISTRATOR]); if (!$adminRole) { throw new \RuntimeException('Administrator role should exist.'); } if ($this->isUserWithRoleExist($manager, $adminRole)) { return; } $businessUnit = $manager->getRepository('OroOrganizationBundle:BusinessUnit')->findOneBy(['name' => LoadOrganizationAndBusinessUnitData::MAIN_BUSINESS_UNIT]); $organization = $this->getReference('default_organization'); $adminUser = $this->userManager->createUser(); $adminUser->setUsername(self::DEFAULT_ADMIN_USERNAME)->setEmail(self::DEFAULT_ADMIN_EMAIL)->setEnabled(true)->setOwner($businessUnit)->setPlainPassword(md5(uniqid(mt_rand(), true)))->addRole($adminRole)->addBusinessUnit($businessUnit)->setOrganization($organization)->addOrganization($organization); $this->userManager->updateUser($adminUser); }
/** * Creates a user * * @param string $username * @param string $email * @param string $firstName * @param string $lastName * @param \DateTime $birthday * @param mixed $role * @return User */ private function createUser($username, $email, $firstName, $lastName, $birthday, $role) { /** @var $user User */ $user = $this->userManager->createUser(); $user->setEmail($email); $user->setUsername($username); $user->setFirstName($firstName); $user->setLastName($lastName); $user->setBirthday($birthday); $user->setOwner($this->getBusinessUnit('Acme, General')); $user->addBusinessUnit($this->getBusinessUnit('Acme, General')); $user->addRole($role); $user->setOrganization($this->organization); $user->addOrganization($this->organization); return $user; }
/** * Creates a user * * @param string $username * @param string $email * @param string $firstName * @param string $lastName * @param string $middleName * @param \DateTime $birthday * @param Organization $organization * @return User */ private function createUser($username, $email, $firstName, $lastName, $middleName, $birthday, $organization) { /** @var $user User */ $user = $this->userManager->createUser(); $user->setEmail($email); $user->setUsername($username); $user->setFirstName($firstName); $user->setMiddlename($middleName); $user->setLastName($lastName); $user->setBirthday($birthday); $user->addRole($this->role[0]); $user->setBusinessUnits(new ArrayCollection([$this->businessUnit])); $user->setOwner($this->businessUnit); $user->setOrganization($organization); $user->addOrganization($organization); return $user; }
protected function getUser() { return $this->userManager->createUser(); }