Skip to content

Commit

Permalink
[Core] Extend multi OAuth providers draft to be more elastic
Browse files Browse the repository at this point in the history
  • Loading branch information
stloyd committed May 9, 2014
1 parent 93475c5 commit 3ab85f1
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 42 deletions.
22 changes: 11 additions & 11 deletions Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Sylius\Component\Core\Model;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use FOS\UserBundle\Model\User as BaseUser;
use Sylius\Component\Addressing\Model\AddressInterface;

Expand All @@ -22,7 +23,6 @@
*/
class User extends BaseUser implements UserInterface
{

protected $firstName;
protected $lastName;
protected $createdAt;
Expand All @@ -33,14 +33,15 @@ class User extends BaseUser implements UserInterface
protected $billingAddress;
protected $shippingAddress;
protected $addresses;
protected $oauths;
protected $oauthAccounts;

public function __construct()
{
$this->createdAt = new \DateTime();
$this->orders = new ArrayCollection();
$this->addresses = new ArrayCollection();
$this->oauths = new ArrayCollection();
$this->createdAt = new \DateTime();
$this->orders = new ArrayCollection();
$this->addresses = new ArrayCollection();
$this->oauthAccounts = new ArrayCollection();

parent::__construct();
}

Expand All @@ -62,7 +63,6 @@ public function setCurrency($currency)
return $this;
}


/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -279,12 +279,12 @@ public function setEmailCanonical($emailCanonical)
}

/**
* Get oauth ids
* Get connect OAuth accounts.
*
* @return \Doctrine\Common\Collections\Collection
* @return Collection|UserOAuth[]
*/
public function getOauths()
public function getOAuthAccounts()
{
return $this->oauths;
return $this->oauthAccounts;
}
}
82 changes: 51 additions & 31 deletions Model/UserOauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,22 @@

namespace Sylius\Component\Core\Model;



/**
* User model.
* User OAuth model.
*
* @author Paweł Jędrzejewski <pawel@sylius.org>
* @author Sergio Marchesini
*/
class UserOauth
class UserOAuth
{

protected $id;
protected $provider;
protected $canonicalId;
protected $user;


protected $identifier;
protected $accessToken;

/**
* @var UserInterface
*/
protected $user;

/**
* Get id
Expand All @@ -40,11 +39,21 @@ public function getId()
}

/**
* Set provider
* Get OAuth provider name.
*
* @return string
*/
public function getProvider()
{
return $this->provider;
}

/**
* Set OAuth provider name.
*
* @param string $provider
*
* @return UserOauth
* @return self
*/
public function setProvider($provider)
{
Expand All @@ -54,52 +63,49 @@ public function setProvider($provider)
}

/**
* Get provider
* Get OAuth identifier.
*
* @return string
*/
public function getProvider()
public function getIdentifier()
{
return $this->provider;
return $this->identifier;
}

/**
* Set canonicalId
* Set OAuth identifier.
*
* @param string $canonicalId
* @param string $identifier
*
* @return UserOauth
* @return self
*/
public function setCanonicalId($canonicalId)
public function setIdentifier($identifier)
{
$this->canonicalId = $canonicalId;
$this->identifier = $identifier;

return $this;
}

/**
* Get canonicalId
* Get OAuth access token.
*
* @return string
*/
public function getCanonicalId()
public function getAccessToken()
{
return $this->canonicalId;
return $this->accessToken;
}




/**
* Set user
* Set OAuth access token.
*
* @param UserInterface $user
* @param string $accessToken
*
* @return UserOauth
* @return self
*/
public function setUser(UserInterface $user = null)
public function setAccessToken($accessToken)
{
$this->user = $user;
$this->accessToken = $accessToken;

return $this;
}
Expand All @@ -113,4 +119,18 @@ public function getUser()
{
return $this->user;
}

/**
* Set user.
*
* @param UserInterface $user
*
* @return self
*/
public function setUser(UserInterface $user)
{
$this->user = $user;

return $this;
}
}

0 comments on commit 3ab85f1

Please sign in to comment.