app/proxy/entity/src/Eccube/Entity/Member.php line 32

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Entity;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  15. use Symfony\Component\Security\Core\User\UserInterface;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. use Symfony\Component\Validator\Mapping\ClassMetadata;
  18.     /**
  19.      * Member
  20.      *
  21.      * @ORM\Table(name="dtb_member")
  22.      * @ORM\InheritanceType("SINGLE_TABLE")
  23.      * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
  24.      * @ORM\HasLifecycleCallbacks()
  25.      * @ORM\Entity(repositoryClass="Eccube\Repository\MemberRepository")
  26.      */
  27.     class Member extends \Eccube\Entity\AbstractEntity implements UserInterface\Serializable
  28.     {
  29.         public static function loadValidatorMetadata(ClassMetadata $metadata)
  30.         {
  31.             $metadata->addConstraint(new UniqueEntity([
  32.                 'fields' => 'login_id',
  33.                 'message' => 'form_error.member_already_exists',
  34.             ]));
  35.         }
  36.         /**
  37.          * @return string
  38.          */
  39.         public function __toString()
  40.         {
  41.             return (string) $this->getName();
  42.         }
  43.         /**
  44.          * {@inheritdoc}
  45.          */
  46.         public function getRoles()
  47.         {
  48.             return ['ROLE_ADMIN'];
  49.         }
  50.         /**
  51.          * {@inheritdoc}
  52.          */
  53.         public function getUsername()
  54.         {
  55.             return $this->login_id;
  56.         }
  57.         /**
  58.          * {@inheritdoc}
  59.          */
  60.         public function eraseCredentials()
  61.         {
  62.         }
  63.         /**
  64.          * @var int
  65.          *
  66.          * @ORM\Column(name="id", type="integer", options={"unsigned":true})
  67.          * @ORM\Id
  68.          * @ORM\GeneratedValue(strategy="IDENTITY")
  69.          */
  70.         private $id;
  71.         /**
  72.          * @var string|null
  73.          *
  74.          * @ORM\Column(name="name", type="string", length=255, nullable=true)
  75.          */
  76.         private $name;
  77.         /**
  78.          * @var string|null
  79.          *
  80.          * @ORM\Column(name="department", type="string", length=255, nullable=true)
  81.          */
  82.         private $department;
  83.         /**
  84.          * @var string
  85.          *
  86.          * @ORM\Column(name="login_id", type="string", length=255)
  87.          */
  88.         private $login_id;
  89.         /**
  90.          * @Assert\NotBlank()
  91.          * @Assert\Length(max=4096)
  92.          */
  93.         private $plainPassword;
  94.         /**
  95.          * @var string
  96.          *
  97.          * @ORM\Column(name="password", type="string", length=255)
  98.          */
  99.         private $password;
  100.         /**
  101.          * @var string
  102.          *
  103.          * @ORM\Column(name="salt", type="string", length=255, nullable=true)
  104.          */
  105.         private $salt;
  106.         /**
  107.          * @var int
  108.          *
  109.          * @ORM\Column(name="sort_no", type="smallint", options={"unsigned":true})
  110.          */
  111.         private $sort_no;
  112.         /**
  113.          * @var string
  114.          *
  115.          * @ORM\Column(name="two_factor_auth_key",type="string",length=255,nullable=true,options={"fixed":false})
  116.          */
  117.         private $two_factor_auth_key;
  118.         /**
  119.          * @ORM\Column(name="two_factor_auth_enabled",type="boolean",nullable=false,options={"default":false})
  120.          *
  121.          * @var integer
  122.          */
  123.         private $two_factor_auth_enabled false;
  124.         /**
  125.          * @var \DateTime
  126.          *
  127.          * @ORM\Column(name="create_date", type="datetimetz")
  128.          */
  129.         private $create_date;
  130.         /**
  131.          * @var \DateTime
  132.          *
  133.          * @ORM\Column(name="update_date", type="datetimetz")
  134.          */
  135.         private $update_date;
  136.         /**
  137.          * @var \DateTime|null
  138.          *
  139.          * @ORM\Column(name="login_date", type="datetimetz", nullable=true)
  140.          */
  141.         private $login_date;
  142.         /**
  143.          * @var \Eccube\Entity\Master\Work
  144.          *
  145.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Work")
  146.          * @ORM\JoinColumns({
  147.          *   @ORM\JoinColumn(name="work_id", referencedColumnName="id")
  148.          * })
  149.          */
  150.         private $Work;
  151.         /**
  152.          * @var \Eccube\Entity\Master\Authority
  153.          *
  154.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Authority")
  155.          * @ORM\JoinColumns({
  156.          *   @ORM\JoinColumn(name="authority_id", referencedColumnName="id")
  157.          * })
  158.          */
  159.         private $Authority;
  160.         /**
  161.          * @var \Eccube\Entity\Member
  162.          *
  163.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Member")
  164.          * @ORM\JoinColumns({
  165.          *   @ORM\JoinColumn(name="creator_id", referencedColumnName="id")
  166.          * })
  167.          */
  168.         private $Creator;
  169.         /**
  170.          * Get id.
  171.          *
  172.          * @return int
  173.          */
  174.         public function getId()
  175.         {
  176.             return $this->id;
  177.         }
  178.         /**
  179.          * Set name.
  180.          *
  181.          * @param string|null $name
  182.          *
  183.          * @return Member
  184.          */
  185.         public function setName($name null)
  186.         {
  187.             $this->name $name;
  188.             return $this;
  189.         }
  190.         /**
  191.          * Get name.
  192.          *
  193.          * @return string|null
  194.          */
  195.         public function getName()
  196.         {
  197.             return $this->name;
  198.         }
  199.         /**
  200.          * Set department.
  201.          *
  202.          * @param string|null $department
  203.          *
  204.          * @return Member
  205.          */
  206.         public function setDepartment($department null)
  207.         {
  208.             $this->department $department;
  209.             return $this;
  210.         }
  211.         /**
  212.          * Get department.
  213.          *
  214.          * @return string|null
  215.          */
  216.         public function getDepartment()
  217.         {
  218.             return $this->department;
  219.         }
  220.         /**
  221.          * Set loginId.
  222.          *
  223.          * @param string $loginId
  224.          *
  225.          * @return Member
  226.          */
  227.         public function setLoginId($loginId)
  228.         {
  229.             $this->login_id $loginId;
  230.             return $this;
  231.         }
  232.         /**
  233.          * Get loginId.
  234.          *
  235.          * @return string
  236.          */
  237.         public function getLoginId()
  238.         {
  239.             return $this->login_id;
  240.         }
  241.         /**
  242.          * @return string|null
  243.          */
  244.         public function getPlainPassword(): ?string
  245.         {
  246.             return $this->plainPassword;
  247.         }
  248.         /**
  249.          * @param string $password
  250.          *
  251.          * @return $this
  252.          */
  253.         public function setPlainPassword(?string $password): self
  254.         {
  255.             $this->plainPassword $password;
  256.             return $this;
  257.         }
  258.         /**
  259.          * Set password.
  260.          *
  261.          * @param string $password
  262.          *
  263.          * @return Member
  264.          */
  265.         public function setPassword($password)
  266.         {
  267.             $this->password $password;
  268.             return $this;
  269.         }
  270.         /**
  271.          * Get password.
  272.          *
  273.          * @return string
  274.          */
  275.         public function getPassword()
  276.         {
  277.             return $this->password;
  278.         }
  279.         /**
  280.          * Set salt.
  281.          *
  282.          * @param string $salt
  283.          *
  284.          * @return Member
  285.          */
  286.         public function setSalt($salt)
  287.         {
  288.             $this->salt $salt;
  289.             return $this;
  290.         }
  291.         /**
  292.          * Get salt.
  293.          *
  294.          * @return string
  295.          */
  296.         public function getSalt()
  297.         {
  298.             return $this->salt;
  299.         }
  300.         /**
  301.          * Set sortNo.
  302.          *
  303.          * @param int $sortNo
  304.          *
  305.          * @return Member
  306.          */
  307.         public function setSortNo($sortNo)
  308.         {
  309.             $this->sort_no $sortNo;
  310.             return $this;
  311.         }
  312.         /**
  313.          * Get sortNo.
  314.          *
  315.          * @return int
  316.          */
  317.         public function getSortNo()
  318.         {
  319.             return $this->sort_no;
  320.         }
  321.         /**
  322.          * Set twoFactorAuthKey.
  323.          *
  324.          * @param string $two_factor_auth_key
  325.          *
  326.          * @return Member
  327.          */
  328.         public function setTwoFactorAuthKey($two_factor_auth_key)
  329.         {
  330.             $this->two_factor_auth_key $two_factor_auth_key;
  331.             return $this;
  332.         }
  333.         /**
  334.          * Get twoFactorAuthKey.
  335.          *
  336.          * @return string
  337.          */
  338.         public function getTwoFactorAuthKey()
  339.         {
  340.             return $this->two_factor_auth_key;
  341.         }
  342.         /**
  343.          * Set twoFactorAuthEnabled.
  344.          *
  345.          * @param boolean $two_factor_auth_enabled
  346.          *
  347.          * @return Member
  348.          */
  349.         public function setTwoFactorAuthEnabled($two_factor_auth_enabled)
  350.         {
  351.             $this->two_factor_auth_enabled $two_factor_auth_enabled;
  352.             return $this;
  353.         }
  354.         /**
  355.          * Get twoFactorAuthEnabled.
  356.          *
  357.          * @return boolean
  358.          */
  359.         public function isTwoFactorAuthEnabled()
  360.         {
  361.             return $this->two_factor_auth_enabled;
  362.         }
  363.         /**
  364.          * Set createDate.
  365.          *
  366.          * @param \DateTime $createDate
  367.          *
  368.          * @return Member
  369.          */
  370.         public function setCreateDate($createDate)
  371.         {
  372.             $this->create_date $createDate;
  373.             return $this;
  374.         }
  375.         /**
  376.          * Get createDate.
  377.          *
  378.          * @return \DateTime
  379.          */
  380.         public function getCreateDate()
  381.         {
  382.             return $this->create_date;
  383.         }
  384.         /**
  385.          * Set updateDate.
  386.          *
  387.          * @param \DateTime $updateDate
  388.          *
  389.          * @return Member
  390.          */
  391.         public function setUpdateDate($updateDate)
  392.         {
  393.             $this->update_date $updateDate;
  394.             return $this;
  395.         }
  396.         /**
  397.          * Get updateDate.
  398.          *
  399.          * @return \DateTime
  400.          */
  401.         public function getUpdateDate()
  402.         {
  403.             return $this->update_date;
  404.         }
  405.         /**
  406.          * Set loginDate.
  407.          *
  408.          * @param \DateTime|null $loginDate
  409.          *
  410.          * @return Member
  411.          */
  412.         public function setLoginDate($loginDate null)
  413.         {
  414.             $this->login_date $loginDate;
  415.             return $this;
  416.         }
  417.         /**
  418.          * Get loginDate.
  419.          *
  420.          * @return \DateTime|null
  421.          */
  422.         public function getLoginDate()
  423.         {
  424.             return $this->login_date;
  425.         }
  426.         /**
  427.          * Set Work
  428.          *
  429.          * @param \Eccube\Entity\Master\Work
  430.          *
  431.          * @return Member
  432.          */
  433.         public function setWork(Master\Work $work null)
  434.         {
  435.             $this->Work $work;
  436.             return $this;
  437.         }
  438.         /**
  439.          * Get work.
  440.          *
  441.          * @return \Eccube\Entity\Master\Work|null
  442.          */
  443.         public function getWork()
  444.         {
  445.             return $this->Work;
  446.         }
  447.         /**
  448.          * Set authority.
  449.          *
  450.          * @param \Eccube\Entity\Master\Authority|null $authority
  451.          *
  452.          * @return Member
  453.          */
  454.         public function setAuthority(Master\Authority $authority null)
  455.         {
  456.             $this->Authority $authority;
  457.             return $this;
  458.         }
  459.         /**
  460.          * Get authority.
  461.          *
  462.          * @return \Eccube\Entity\Master\Authority|null
  463.          */
  464.         public function getAuthority()
  465.         {
  466.             return $this->Authority;
  467.         }
  468.         /**
  469.          * Set creator.
  470.          *
  471.          * @param \Eccube\Entity\Member|null $creator
  472.          *
  473.          * @return Member
  474.          */
  475.         public function setCreator(Member $creator null)
  476.         {
  477.             $this->Creator $creator;
  478.             return $this;
  479.         }
  480.         /**
  481.          * Get creator.
  482.          *
  483.          * @return \Eccube\Entity\Member|null
  484.          */
  485.         public function getCreator()
  486.         {
  487.             return $this->Creator;
  488.         }
  489.         /**
  490.          * String representation of object
  491.          *
  492.          * @see http://php.net/manual/en/serializable.serialize.php
  493.          *
  494.          * @return string the string representation of the object or null
  495.          *
  496.          * @since 5.1.0
  497.          */
  498.         public function serialize()
  499.         {
  500.             // see https://symfony.com/doc/2.7/security/entity_provider.html#create-your-user-entity
  501.             // MemberRepository::loadUserByUsername() で Work をチェックしているため、ここでは不要
  502.             return serialize([
  503.                 $this->id,
  504.                 $this->login_id,
  505.                 $this->password,
  506.                 $this->salt,
  507.             ]);
  508.         }
  509.         /**
  510.          * Constructs the object
  511.          *
  512.          * @see http://php.net/manual/en/serializable.unserialize.php
  513.          *
  514.          * @param string $serialized <p>
  515.          * The string representation of the object.
  516.          * </p>
  517.          *
  518.          * @return void
  519.          *
  520.          * @since 5.1.0
  521.          */
  522.         public function unserialize($serialized)
  523.         {
  524.             list(
  525.                 $this->id,
  526.                 $this->login_id,
  527.                 $this->password,
  528.                 $this->salt) = unserialize($serialized);
  529.         }
  530.     }