Пример #1
0
 /**
  * @param User $user
  *
  * @return array
  */
 public function getUserProjectIds(User $user)
 {
     $queryBuilder = $this->createQueryBuilder('p')->select('p.id')->where('p.user = :user_id')->setParameter('user_id', $user->getId());
     $rawResult = $queryBuilder->getQuery()->getArrayResult();
     $results = [];
     foreach ($rawResult as $result) {
         $results[] = $result['id'];
     }
     return $results;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $superAdmin = new User();
     $superAdmin->setUsername('superadmin');
     $superAdmin->setEmail('*****@*****.**');
     $superAdmin->setPlainPassword('pass123');
     $superAdmin->setRoles(['ROLE_SUPERADMIN']);
     $superAdmin->setEnabled(true);
     $userAdmin = new User();
     $userAdmin->setUsername('admin');
     $userAdmin->setEmail('*****@*****.**');
     $userAdmin->setPlainPassword('pass123');
     $userAdmin->setRoles(['ROLE_ADMIN']);
     $userAdmin->setEnabled(true);
     $visitor1 = new User();
     $visitor1->setUsername('visitor1');
     $visitor1->setEmail('*****@*****.**');
     $visitor1->setPlainPassword('pass123');
     $visitor1->setGithubUserName(getenv('GITHUB_USERNAME'));
     $visitor1->setGithubAccessToken(getenv('GITHUB_ACCESS_TOKEN'));
     $visitor1->setRoles(['ROLE_USER']);
     $visitor1->setEnabled(true);
     $disabledUser1 = new User();
     $disabledUser1->setUsername('disabledUser1');
     $disabledUser1->setEmail('*****@*****.**');
     $disabledUser1->setPlainPassword('pass123');
     $disabledUser1->setRoles(['ROLE_USER']);
     $disabledUser1->setEnabled(false);
     $manager->persist($superAdmin);
     $manager->persist($userAdmin);
     $manager->persist($visitor1);
     $manager->persist($disabledUser1);
     $manager->flush();
     $this->addReference('user-superadmin', $superAdmin);
     $this->addReference('user-admin', $userAdmin);
     $this->addReference('user-visitor1', $visitor1);
     $this->addReference('user-disabledUser1', $disabledUser1);
 }
 /**
  * @param User $user
  *
  * @return Client
  */
 public function create(User $user)
 {
     $client = new Client();
     $client->authenticate($user->getGithubAccessToken(), 'null', 'url_token');
     return $client;
 }
Пример #4
0
 /**
  * @param User $user
  */
 private function logUserIn(User $user)
 {
     $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
     $this->getService('security.context')->setToken($token);
 }