<?php
namespace Customize\EventSubscriber;
use Doctrine\ORM\EntityManagerInterface;
use Eccube\Entity\Customer;
use Eccube\Event\EventArgs;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class EntryPointSubscriber implements EventSubscriberInterface
{
/**
* @var EntityManagerInterface
*/
private $entityManager;
public function __construct(EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
}
public function onFrontEntryActivateComplete(EventArgs $event)
{
$Customer = $event->getArgument("Customer");
if($Customer instanceof Customer) {
// 会員登録完了時に1000ポイント付与
$Customer->setPoint(1000);
$this->entityManager->persist($Customer);
$this->entityManager->flush();
}
}
public static function getSubscribedEvents()
{
return [
'front.entry.activate.complete' => 'onFrontEntryActivateComplete',
];
}
}