/**
  * @param string      $name
  * @param string|null $group
  * @return User
  */
 protected function generate($name, $group = null)
 {
     $user = new User();
     $user->setFirstName($name);
     $user->setLastName($name);
     $user->setEmail($name . '@fixtures.com');
     $user->setUsername($name);
     $user->setPlainPassword($name);
     if ($group) {
         $user->addGroup($this->getReference($group));
     }
     $user->setEnabled(true);
     return $user;
 }
 /**
  * @param User                $mixed
  * @param GroupInterface|null $group
  *
  * @return FacadeInterface
  */
 public function transform($mixed, GroupInterface $group = null)
 {
     $facade = $this->newFacade();
     $facade->username = $mixed->getUsername();
     $facade->firstName = $mixed->getFirstName();
     $facade->lastName = $mixed->getLastName();
     $facade->email = $mixed->getEmail();
     if (null !== $group && $this->authorizationChecker->isGranted(AdministrationPanelStrategy::ROLE_ACCESS_UPDATE_USER)) {
         $facade->addLink('_self_delete', $this->generateRoute('open_orchestra_api_user_remove_group', array('userId' => $mixed->getId(), 'groupId' => $group->getId())));
         $facade->addLink('_self_add', $this->generateRoute('open_orchestra_api_user_add_group', array('userId' => $mixed->getId(), 'groupId' => $group->getId())));
     }
     return $facade;
 }