Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $userToken = new AccessToken();
     $userToken->setClient($this->getReference('client'));
     $userToken->setUser($this->getReference('user-admin'));
     $userToken->setToken('testToken');
     $userToken->setExpiresAt(time() + 100000000);
     $manager->persist($userToken);
     $manager->flush();
 }
Пример #2
0
 /**
  * @param $username
  *
  * @return AccessToken
  */
 private function getAccessToken($username)
 {
     $token = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
     $client = $this->getOAuthClient();
     $user = $this->getUser($username);
     $expireAt = strtotime('+1 year');
     $accessToken = $this->getDoctrine()->getRepository('AppBundle:AccessToken')->findOneBy(['token' => $token]);
     if (!$accessToken) {
         $accessToken = new AccessToken();
     }
     $accessToken->setToken($token);
     $accessToken->setClient($client);
     $accessToken->setUser($user);
     $accessToken->setExpiresAt($expireAt);
     $manager = $this->getDoctrine()->getManager();
     $manager->persist($accessToken);
     $manager->flush();
     return $accessToken;
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     /** @var Client $oauthClient */
     $oauthClient = $this->getReference('oauth-client');
     /** @var User $firstUser */
     $firstUser = $this->getReference('user-1');
     /** @var User $secondUser */
     $secondUser = $this->getReference('user-2');
     $adminAccessToken = new AccessToken();
     $adminAccessToken->setClient($oauthClient);
     $adminAccessToken->setUser($firstUser);
     $adminAccessToken->setExpiresAt(strtotime('+' . $this->container->getParameter('df_admin_access_token_expire')));
     $adminAccessToken->setToken($this->container->getParameter('df_admin_access_token'));
     $manager->persist($adminAccessToken);
     $userAccessToken = new AccessToken();
     $userAccessToken->setClient($oauthClient);
     $userAccessToken->setUser($secondUser);
     $userAccessToken->setExpiresAt(strtotime('+' . $this->container->getParameter('df_user_access_token_expire')));
     $userAccessToken->setToken($this->container->getParameter('df_user_access_token'));
     $manager->persist($userAccessToken);
     $manager->flush();
 }