Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // src/AppBundle/Entity/User.php
- namespace AppBundleEntity;
- use DoctrineORMMapping as ORM;
- use SymfonyComponentSecurityCoreUserUserInterface;
- /**
- * @ORMTable(name="entity")
- * @ORMEntity(repositoryClass="AppBundleEntityUserRepository")
- */
- class Entity
- {
- /**
- * @ORMColumn(type="integer")
- * @ORMId
- * @ORMGeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @ORMColumn(type="string", length=25, unique=true)
- */
- private $label;
- /**
- * @ORMColumn(type="string", length=4096, options={"default" = "DBQ="})
- */
- private $dsn;
- /**
- * @ORMColumn(type="string", length=4096, options={"default" = ""})
- */
- private $entityName;
- /**
- * @ORMOneToMany(targetEntity="UserEntity", mappedBy="entity", cascade={"all"})
- * */
- protected $userEntities;
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Get label
- *
- * @return string
- */
- public function getLabel()
- {
- return $this->label;
- }
- /**
- * Set label
- *
- * @param string label
- *
- * @return User
- */
- public function setLabel($label)
- {
- $this->label = $label;
- return $this;
- }
- /**
- * Get dsn
- *
- * @return string
- */
- public function getDsn()
- {
- return $this->dsn;
- }
- /**
- * Set dsn
- *
- * @param string dsn
- *
- * @return User
- */
- public function setDsn($dsn)
- {
- $this->dsn = $dsn;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getEntityName()
- {
- return $this->entityName;
- }
- /**
- * @param mixed $entityName
- */
- public function setEntityName($entityName)
- {
- $this->entityName = $entityName;
- }
- /** @see Serializable::serialize() */
- public function serialize()
- {
- return serialize(array(
- $this->id,
- $this->label
- ));
- }
- /** @see Serializable::unserialize() */
- public function unserialize($serialized)
- {
- list (
- $this->id,
- $this->label
- ) = unserialize($serialized);
- }
- public function __toString() {
- return $this->label;
- }
- /**
- * Constructor
- */
- public function __construct()
- {
- $this->userEntity = new DoctrineCommonCollectionsArrayCollection();
- }
- /**
- * Add userEntity
- *
- * @param AppBundleEntityUserEntity $userEntity
- *
- * @return User
- */
- public function addUserEntity(AppBundleEntityUserEntity $userEntity)
- {
- $this->userEntities[] = $userEntity;
- return $this;
- }
- /**
- * Remove userEntity
- *
- * @param AppBundleEntityUserEntity $userEntity
- */
- public function removeUserEntity(AppBundleEntityUserEntity $userEntity)
- {
- $this->userEntities->removeElement($userEntity);
- }
- /**
- * Get userEntities
- *
- * @return DoctrineCommonCollectionsCollection
- */
- public function getUserEntities()
- {
- return $this->userEntities;
- }
- }
- <?php
- // src/AppBundle/Entity/User.php
- namespace AppBundleEntity;
- use SymfonyComponentValidatorConstraints as Assert;
- use DoctrineORMMapping as ORM;
- use SymfonyComponentSecurityCoreUserUserInterface;
- use DoctrineCommonCollectionsArrayCollection;
- /**
- * @ORMTable(name="user")
- * @ORMEntity(repositoryClass="AppBundleEntityUserRepository")
- */
- class User implements UserInterface, Serializable
- {
- /**
- * @ORMColumn(type="integer")
- * @ORMId
- * @ORMGeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @ORMColumn(type="string", length=25, unique=true)
- */
- private $username;
- /**
- * @ORMColumn(type="string", length=64)
- */
- private $password;
- /**
- * @ORMColumn(type="string", length=60, unique=true)
- */
- private $email;
- /**
- * @AssertLength(max = 4096)
- */
- private $plainPassword;
- /**
- * @ORMOneToMany(targetEntity="UserEntity", mappedBy="user", cascade={"all"})
- * */
- protected $userEntities;
- /**
- * @ORMManyToMany(targetEntity="Role")
- * @ORMJoinTable(name="users_roles",
- * joinColumns={@ORMJoinColumn(name="user_id", referencedColumnName="id")},
- * inverseJoinColumns={@ORMJoinColumn(name="role_id", referencedColumnName="id")}
- * )
- */
- private $roles;
- /**
- * @ORMColumn(name="is_active", type="boolean")
- */
- private $isActive;
- public function __construct()
- {
- $this->isActive = true;
- $this->entities = new ArrayCollection();
- $this->roles = new ArrayCollection();
- // may not be needed, see section on salt below
- // $this->salt = md5(uniqid(null, true));
- }
- public function getUsername()
- {
- return $this->username;
- }
- public function getSalt()
- {
- // you *may* need a real salt depending on your encoder
- // see section on salt below
- return null;
- }
- public function getPassword()
- {
- return $this->password;
- }
- public function getRoles()
- {
- return $this->roles->toArray();
- }
- public function eraseCredentials()
- {
- }
- /** @see Serializable::serialize() */
- public function serialize()
- {
- return serialize(array(
- $this->id,
- $this->username,
- $this->password,
- // see section on salt below
- // $this->salt,
- ));
- }
- /** @see Serializable::unserialize() */
- public function unserialize($serialized)
- {
- list (
- $this->id,
- $this->username,
- $this->password,
- // see section on salt below
- // $this->salt
- ) = unserialize($serialized);
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set username
- *
- * @param string $username
- *
- * @return User
- */
- public function setUsername($username)
- {
- $this->username = $username;
- return $this;
- }
- public function getPlainPassword()
- {
- return $this->plainPassword;
- }
- public function setPlainPassword($password)
- {
- $this->plainPassword = $password;
- }
- /**
- * Set password
- *
- * @param string $password
- *
- * @return User
- */
- public function setPassword($password)
- {
- if (!is_null($password)) {
- $this->password = $password;
- }
- return $this;
- }
- /**
- * Set email
- *
- * @param string $email
- *
- * @return User
- */
- public function setEmail($email)
- {
- $this->email = $email;
- return $this;
- }
- /**
- * Get email
- *
- * @return string
- */
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * Set isActive
- *
- * @param boolean $isActive
- *
- * @return User
- */
- public function setIsActive($isActive)
- {
- $this->isActive = $isActive;
- return $this;
- }
- /**
- * Get isActive
- *
- * @return boolean
- */
- public function getIsActive()
- {
- return $this->isActive;
- }
- /**
- * Add role
- *
- * @param AppBundleEntityRole $role
- *
- * @return User
- */
- public function addRole(AppBundleEntityRole $role)
- {
- $this->roles[] = $role;
- return $this;
- }
- /**
- * Remove role
- *
- * @param AppBundleEntityRole $role
- */
- public function removeRole($role)
- {
- $this->roles->removeElement($role);
- }
- /**
- * Add userEntity
- *
- * @param AppBundleEntityUserEntity $userEntity
- *
- * @return User
- */
- public function addUserEntity(AppBundleEntityUserEntity $userEntity)
- {
- $this->userEntities[] = $userEntity;
- return $this;
- }
- /**
- * Remove userEntity
- *
- * @param AppBundleEntityUserEntity $userEntity
- */
- public function removeUserEntity(AppBundleEntityUserEntity $userEntity)
- {
- $this->userEntities->removeElement($userEntity);
- }
- /**
- * Get userEntities
- *
- * @return DoctrineCommonCollectionsCollection
- */
- public function getUserEntities()
- {
- return $this->userEntities;
- }
- }
- <?php
- // src/AppBundle/Entity/User.php
- namespace AppBundleEntity;
- use DoctrineORMMapping as ORM;
- use SymfonyComponentSecurityCoreUserUserInterface;
- /**
- * @ORMTable(name="user_entity")
- * @ORMEntity(repositoryClass="AppBundleEntityUserRepository")
- * @ORMHasLifecycleCallbacks()
- */
- class UserEntity
- {
- /**
- * @ORMColumn(type="integer")
- * @ORMId
- * @ORMGeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @ORMManyToOne(targetEntity="User", inversedBy="userEntities")
- * @ORMJoinColumn(name="u_id", referencedColumnName="id")
- * */
- protected $user;
- /**
- * @ORMManyToOne(targetEntity="Entity", inversedBy="userEntities")
- * @ORMJoinColumn(name="e_id", referencedColumnName="id")
- * */
- protected $entity;
- /**
- * UserEntity constructor.
- * @param $user
- * @param $entity
- */
- public function __construct($user, $entity)
- {
- $this->user = $user;
- $this->entity = $entity;
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set user
- *
- * @param AppBundleEntityUser $user
- *
- * @return UserEntity
- */
- public function setUser(AppBundleEntityUser $user = null)
- {
- $this->user = $user;
- return $this;
- }
- /**
- * Get user
- *
- * @return AppBundleEntityUser
- */
- public function getUser()
- {
- return $this->user;
- }
- /**
- * Set entity
- *
- * @param AppBundleEntityEntity $entity
- *
- * @return UserEntity
- */
- public function setEntity(AppBundleEntityEntity $entity = null)
- {
- $this->entity = $entity;
- return $this;
- }
- /**
- * Get entity
- *
- * @return AppBundleEntityEntity
- */
- public function getEntity()
- {
- return $this->entity;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement