Created
July 20, 2016 11:54
-
-
Save VincentChalnot/1c580dcc2a6b7e3e2c699437be408e6d to your computer and use it in GitHub Desktop.
User class example for Sidus/EncryptionBundle with FOS/UserBundle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MyNameSpace\UserBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
use FOS\UserBundle\Model\User as BaseUser; | |
use Sidus\EncryptionBundle\Entity\UserEncryptionProviderInterface; | |
/** | |
* @ORM\Entity(repositoryClass="MyNameSpace\UserBundle\Entity\UserRepository") | |
* @ORM\Table(name="mynamespace_user") | |
*/ | |
class User extends BaseUser implements UserEncryptionProviderInterface | |
{ | |
/** | |
* @ORM\Id | |
* @ORM\Column(type="integer") | |
* @ORM\GeneratedValue(strategy="AUTO") | |
*/ | |
protected $id; | |
/** | |
* @ORM\Column(type="string", name="encrypted_cipher_key", nullable=true) | |
*/ | |
protected $encryptedCipherKey; | |
/** | |
* Get id | |
* | |
* @return integer | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* @return mixed Binary data | |
*/ | |
public function getEncryptedCipherKey() | |
{ | |
return hex2bin($this->encryptedCipherKey); | |
} | |
/** | |
* @param mixed $encryptedCipherKey | |
* | |
* @return User | |
*/ | |
public function setEncryptedCipherKey($encryptedCipherKey) | |
{ | |
$this->encryptedCipherKey = bin2hex($encryptedCipherKey); | |
return $this; | |
} | |
/** | |
* @return int | |
*/ | |
public function getEncryptionOwnershipId() | |
{ | |
// If you want to share data between a group, return the id of the group. | |
// If you want the data to be accessible by the current user only : | |
return $this->getId(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment