/** * @param User $user * * @return User */ public function save(User $user) { $updatedAt = new \DateTime(); $user->setUpdatedAt($updatedAt); $this->_em->persist($user); $this->_em->flush(); return $user; }
public function load(ObjectManager $manager) { $userPassword = '******'; $date = new \DateTime(); $user = new User(); $user->setUsername($userPassword); $user->setEmail('*****@*****.**'); $user->setFullName('super administrator'); $user->setRoles(array('ROLE_SUPER_ADMIN')); $user->setPlainPassword($userPassword); $user->setEnabled(true); $user->setCreatedAt($date); $user->setUpdatedAt($date); $user->setCreatedBy('SYSTEM'); $user->setUpdatedBy('SYSTEM'); $manager->persist($user); $manager->flush(); }
public function update(User $user, $firstname, $lastname, $email, $username, $password, $about, $picture, $location, $locationCityShort, $locationCityLong, $locationStateShort, $locationStateLong, $locationCountryShort, $locationCountryLong, $gender, $company, $isAvailableToHiring, $contactWebsite, $contactTwitter, $contactLinkedIn, $contactCertification, $contactGitHub, $contactStackOverflow) { if ($errors = $this->getErrors($firstname, $lastname, $email, $username, $password, $about, $locationCityShort, $locationCityLong, $locationStateShort, $locationStateLong, $locationCountryShort, $locationCountryLong, $gender, $company, $isAvailableToHiring, true, $password == '' ? false : true)) { throw new ServiceException($errors); } $user->setUsername($username); $user->setFirstname($firstname); $user->setLastname($lastname); $user->setEmail($email); $user->setAbout($about); $user->setLocation($location); $user->setLocationCityShort($locationCityShort); $user->setLocationCityLong($locationCityLong); $user->setLocationStateShort($locationStateShort); $user->setLocationStateLong($locationStateLong); $user->setLocationCountryShort($locationCountryShort); $user->setLocationCountryLong($locationCountryLong); $user->setGender($gender); $user->setCompany($company); $user->setIsAvailableToHiring($isAvailableToHiring); $user->setContactWebsite($contactWebsite); $user->setContactTwitter($contactTwitter); $user->setContactLinkedIn($contactLinkedIn); $user->setContactCertification($contactCertification); $user->setContactGitHub($contactGitHub); $user->setContactStackOverflow($contactStackOverflow); $user->setUpdatedAt(new \DateTime()); if ($picture) { $user->setPicturePath($this->moveImageFromTmpToFolder($picture)); } if ($password) { $user->setPassword(md5($password)); } return $this->repository->create($user); }