/** * @param string $username * * @return User */ public function user($username, $withWorkspace = false) { $user = new User(); $user->setFirstName($username); $user->setLastName($username); $user->setUsername($username); $user->setPassword($username); $user->setMail($username . '@mail.com'); $user->setGuid($username); $this->om->persist($user); if (!$this->userRole) { $this->userRole = $this->role('ROLE_USER'); $this->om->persist($this->userRole); } $user->addRole($this->userRole); if ($withWorkspace) { $workspace = new Workspace(); $workspace->setName($username); $workspace->setCreator($user); $workspace->setCode($username); $workspace->setGuid($username); $this->om->persist($workspace); $user->setPersonalWorkspace($workspace); } return $user; }
public function user($username) { $user = new User(); $user->setFirstName($username); $user->setLastName($username); $user->setUsername($username); $user->setPassword($username); $user->setMail($username . '@mail.com'); $user->setGuid($username); $this->om->persist($user); if (!$this->userRole) { $this->userRole = new Role(); $this->userRole->setName('ROLE_USER'); $this->userRole->setTranslationKey('user'); $this->om->persist($this->userRole); } $user->addRole($this->userRole); $workspace = new Workspace(); $workspace->setName($username); $workspace->setCreator($user); $workspace->setCode($username); $workspace->setGuid($username); $this->om->persist($workspace); $user->setPersonalWorkspace($workspace); $this->om->flush(); return $user; }
private function buildUser($firstName, $lastName) { $user = new User(); $user->setFirstName($firstName); $user->setLastName($lastName); $user->setUsername($username = strtolower($firstName . $lastName)); $user->setPassword($username); $user->setMail("{$username}@mail.com"); return $user; }
protected function persistUser($username) { $user = new User(); $user->setFirstName($username); $user->setLastName($username); $user->setUsername($username); $user->setPassword($username); $user->setGuid($username); $user->setMail($username . '@mail.com'); $this->om->persist($user); return $user; }
/** * @param string $username * @return User */ public function user($username) { $roleUser = $this->om->getRepository('ClarolineCoreBundle:Role')->findOneByName('ROLE_USER'); if (!$roleUser) { $this->role('ROLE_USER'); $this->om->flush(); //we really need it } $user = new User(); $user->setFirstName($username); $user->setLastName($username); $user->setUsername($username); $user->setPassword($username); $user->setMail($username . '@mail.com'); //much better $this->container->get('claroline.manager.user_manager')->createUser($user, false); return $user; }
/** * @param $username * * @return User */ public function user($username) { $user = new User(); $user->setFirstName($username); $user->setLastName($username); $user->setUsername($username); $user->setPassword($username); $user->setMail($username . '@mail.com'); $user->setGuid($username); $this->om->persist($user); $user->addRole($this->userRole); $workspace = new Workspace(); $workspace->setName($username); $workspace->setCreator($user); $workspace->setCode($username); $workspace->setGuid($username); $this->om->persist($workspace); $user->setPersonalWorkspace($workspace); return $user; }
public function user($username) { $user = new User(); $user->setFirstName($username); $user->setLastName($username); $user->setUsername($username); $user->setPassword($username); $user->setMail($username . '@mail.com'); $user->setGuid($username); $user->setPublicUrl($username); $this->om->persist($user); if (!$this->userRole) { $this->userRole = $this->om->getRepository('ClarolineCoreBundle:Role')->findOneByName('ROLE_USER'); } $user->addRole($this->userRole); $workspace = new Workspace(); $workspace->setName($username); $workspace->setCreator($user); $workspace->setCode($username); $workspace->setGuid($username); $this->om->persist($workspace); $user->setPersonalWorkspace($workspace); return $user; }
private function createActivity($name) { $user = new User(); $user->setFirstName('John'); $user->setLastName('Doe'); $user->setUsername('jdoe'); $user->setMail('*****@*****.**'); $user->setPassword('123'); $workspace = new Workspace(); $workspace->setName('w1'); $workspace->setCode('abc'); $workspace->setGuid('abc123'); $workspace->setCreator($user); $type = new ResourceType(); $type->setName('activity'); $node = new ResourceNode(); $node->setName($name); $node->setClass('FooClass'); $node->setCreator($user); $node->setResourceType($type); $node->setWorkspace($workspace); $activity = new Activity(); $activity->setResourceNode($node); $activity->setDescription('activity...'); $this->om->persist($user); $this->om->persist($workspace); $this->om->persist($type); $this->om->persist($node); $this->om->persist($activity); return $activity; }