Created
April 11, 2016 13:54
-
-
Save kurozumi/1955626debf036b39dd0c1fb995c956f to your computer and use it in GitHub Desktop.
【EC-CUBE3】会員IDでログインできるようにする方法
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 Plugin\CustomerLogin\Repository; | |
use Eccube\Repository\CustomerRepository as BaseRepository; | |
use Eccube\Entity\Master\CustomerStatus; | |
use Eccube\Common\Constant; | |
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; | |
class CustomerRepository extends BaseRepository | |
{ | |
public function loadUserByUsername($username) | |
{ | |
// 本会員ステータスの会員のみ有効. | |
$CustomerStatus = $this | |
->getEntityManager() | |
->getRepository('Eccube\Entity\Master\CustomerStatus') | |
->find(CustomerStatus::ACTIVE); | |
$query = $this->createQueryBuilder('c') | |
->where('c.email = :email') | |
->orWhere('c.id = :id') | |
->andWhere('c.del_flg = :delFlg') | |
->andWhere('c.Status =:CustomerStatus') | |
->setParameters(array( | |
'email' => $username, | |
'id' => $username, | |
'delFlg' => Constant::DISABLED, | |
'CustomerStatus' => $CustomerStatus, | |
)) | |
->getQuery(); | |
$Customer = $query->getOneOrNullResult(); | |
if (!$Customer) { | |
throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username)); | |
} | |
return $Customer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment