?? GreyFile — Mystic File Browser

Current path: home/webdevt/cryptoimpot.fr/module/User/src/Entity/



?? Go up: /home/webdevt/cryptoimpot.fr/module/User/src

?? Viewing: User.php

<?php
namespace User\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * This class represents a registered user.
 * @ORM\Entity(repositoryClass="\User\Repository\UserRepository")
 * @ORM\Table(name="user")
 */
class User 
{
    // User status constants.
    const STATUS_ACTIVE       = 1; // Active user.
    const STATUS_RETIRED      = 2; // Retired user.
    
    /**
     * @ORM\Id
     * @ORM\Column(name="id")
     * @ORM\GeneratedValue
     */
    protected $id;

    /** 
     * @ORM\Column(name="email")  
     */
    protected $email;
    
    /** 
     * @ORM\Column(name="full_name")  
     */
    protected $fullName;

    /** 
     * @ORM\Column(name="password")  
     */
    protected $password;

    /** 
     * @ORM\Column(name="status")  
     */
    protected $status;
    
    /**
     * @ORM\Column(name="date_created")  
     */
    protected $dateCreated;
        
    /**
     * @ORM\Column(name="pwd_reset_token")  
     */
    protected $passwordResetToken;
    
    /**
     * @ORM\Column(name="pwd_reset_token_creation_date")  
     */
    protected $passwordResetTokenCreationDate;
    
    /**
     * @ORM\OneToMany(targetEntity="\Application\Entity\Ledgio", mappedBy="user", fetch="EXTRA_LAZY")
     */
    private $ledgios;
    
    /**
     * Many Users have Many Exchanges.
     * @ORM\ManyToMany(targetEntity="\Application\Entity\Exchange")
     * @ORM\JoinTable(name="users_exchanges",
     *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
     *      inverseJoinColumns={@ORM\JoinColumn(name="exchange_id", referencedColumnName="id")}
     *      )
     */
    protected $exchanges;
    
    public function __construct()
    {
        $this->ledgios = new \Doctrine\Common\Collections\ArrayCollection();
    }
    
    /**
     * Returns user ID.
     * @return integer
     */
    public function getId() 
    {
        return $this->id;
    }

    /**
     * Sets user ID. 
     * @param int $id    
     */
    public function setId($id) 
    {
        $this->id = $id;
    }

    /**
     * Returns email.     
     * @return string
     */
    public function getEmail() 
    {
        return $this->email;
    }

    /**
     * Sets email.     
     * @param string $email
     */
    public function setEmail($email) 
    {
        $this->email = $email;
    }
    
    /**
     * Returns full name.
     * @return string     
     */
    public function getFullName() 
    {
        return $this->fullName;
    }       

    /**
     * Sets full name.
     * @param string $fullName
     */
    public function setFullName($fullName) 
    {
        $this->fullName = $fullName;
    }
    
    /**
     * Returns status.
     * @return int     
     */
    public function getStatus() 
    {
        return $this->status;
    }

    /**
     * Returns possible statuses as array.
     * @return array
     */
    public static function getStatusList() 
    {
        return [
            self::STATUS_ACTIVE => 'Active',
            self::STATUS_RETIRED => 'Retired'
        ];
    }    
    
    /**
     * Returns user status as string.
     * @return string
     */
    public function getStatusAsString()
    {
        $list = self::getStatusList();
        if (isset($list[$this->status]))
            return $list[$this->status];
        
        return 'Unknown';
    }    
    
    /**
     * Sets status.
     * @param int $status     
     */
    public function setStatus($status) 
    {
        $this->status = $status;
    }   
    
    /**
     * Returns password.
     * @return string
     */
    public function getPassword() 
    {
       return $this->password; 
    }
    
    /**
     * Sets password.     
     * @param string $password
     */
    public function setPassword($password) 
    {
        $this->password = $password;
    }
    
    /**
     * Returns the date of user creation.
     * @return string     
     */
    public function getDateCreated() 
    {
        return $this->dateCreated;
    }
    
    /**
     * Sets the date when this user was created.
     * @param string $dateCreated     
     */
    public function setDateCreated($dateCreated) 
    {
        $this->dateCreated = $dateCreated;
    }    
    
    /**
     * Returns password reset token.
     * @return string
     */
    public function getPasswordResetToken()
    {
        return $this->passwordResetToken;
    }
    
    /**
     * Sets password reset token.
     * @param string $token
     */
    public function setPasswordResetToken($token) 
    {
        $this->passwordResetToken = $token;
    }
    
    /**
     * Returns password reset token's creation date.
     * @return string
     */
    public function getPasswordResetTokenCreationDate()
    {
        return $this->passwordResetTokenCreationDate;
    }
    
    /**
     * Sets password reset token's creation date.
     * @param string $date
     */
    public function setPasswordResetTokenCreationDate($date) 
    {
        $this->passwordResetTokenCreationDate = $date;
    }
    
    
    /**
     * @return Collection|App\Entity\Ledgio[]
     */
    public function getLedgios(): \Doctrine\Common\Collections\Collection
    {
        return $this->ledgios;
    }
    
    
    public function addLedgio(\Application\Entity\Ledgio $ledgio)
    {
        if (!$this->ledgios->contains($ledgio)) {
            $this->ledgios[] = $ledgio;
            $ledgio->setUser($this);
        }
        return $this;
    }
    public function removeLedgio(\Application\Entity\Ledgio $ledgio)
    {
        if ($this->ledgios->contains($ledgio)) {
            $this->ledgios->removeElement($ledgio);
            // set the owning side to null (unless already changed)
            if ($ledgio->getUser() === $this) {
                $ledgio->setUser(null);
            }
        }
        return $this;
    }
    
    function getExchanges() {
        return $this->exchanges;
    }

    function setExchanges($exchanges) {
        $this->exchanges = $exchanges;
    }
    
    public function removeExchange(\Application\Entity\Exchange $exchange)
    {
        if ($this->exchanges->contains($exchange)) {
            $this->exchanges->removeElement($exchange);
            // set the owning side to null (unless already changed)
//            if ($ledgio->getUser() === $this) {
//                $ledgio->setUser(null);
//            }
        }
        return $this;
    }
    
    public function addExchange(\Application\Entity\Exchange $exchange)
    {
        if (!$this->exchanges->contains($exchange)) {
            $this->exchanges[] = $exchange;
            //$ledgio->setUser($this);
        }
        return $this;
    }


    public function isAdmin() {
        $explodeEmail = explode('@', $this->getEmail());
        $explodeEmail2 =  explode('+', $explodeEmail[0]);

        if ($explodeEmail2[0] != 'jimmykurc' || $explodeEmail[1] != 'gmail.com') {
            return false;
        }

        return true;
    }



}





??

??