Ejemplo n.º 1
0
 /**
  * Gets the description of a given scope key, if
  * available, otherwise the key is returned.
  *
  * @return
  * string description of the scope key.
  */
 public function getDescriptionForScope($scope)
 {
     // Get Scope
     $scopeObject = $this->sm->findScopeByScope($scope);
     if (!$scopeObject) {
         return $scope;
     }
     return $scopeObject->getDescription();
 }
Ejemplo n.º 2
0
 /**
  * Creates a new client
  *
  * @param string $identifier
  *
  * @param array $redirect_uris
  *
  * @param array $grant_type
  *
  * @param array $scopes
  *
  * @return Client
  */
 public function createClient($identifier, array $redirect_uris = array(), array $grant_types = array(), array $scopes = array())
 {
     $client = new \OAuth2\ServerBundle\Entity\Client();
     $client->setClientId($identifier);
     $client->setClientSecret($this->generateSecret());
     $client->setRedirectUri($redirect_uris);
     $client->setGrantTypes($grant_types);
     // Verify scopes
     foreach ($scopes as $scope) {
         // Get Scope
         $scopeObject = $this->sm->findScopeByScope($scope);
         if (!$scopeObject) {
             throw new ScopeNotFoundException();
         }
     }
     $client->setScopes($scopes);
     // Store Client
     $this->em->persist($client);
     $this->em->flush();
     return $client;
 }