Jun 8, 2021 4:40 AM - edited Jun 8, 2021 4:48 AM
class UserListener extends AbstractVopListener
{
/** @var LoggerInterface */
private LoggerInterface $logger;
public function __construct(EventDispatcherInterface $eventDispatcher, EntityManagerInterface $entityManager, LoggerInterface $logger)
{
parent::__construct($eventDispatcher, $entityManager);
$this->logger = $logger;
}
public function onUserCreated(UserEvent $event): void
{
$this->logger->alert('Debug hubspot: onUserCreated started');
$user = $event->getUser();
if ($this->isEligible($user)) {
$this->logger->alert('Debug hubspot: onUserCreated is eligible');
$this->eventDispatcher->dispatch(
ContactCreateEvent::NAME,
new ContactCreateEvent($user)
);
}
}
// other functions
}
services.xml:
<service id="Vop\Marketing\HubSpotBundle\EventListener\UserListener" autoconfigure="false">
<tag name="kernel.event_listener" event="vop_user.event.user_created" method="onUserCreated" />
<tag name="kernel.event_listener" event="vop_user.event.user_updated" method="onUserUpdated" />
</service>
UserEntityListener.php
class UserEntityListener implements EventSubscriber
{
public function postPersist(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
if (!$entity instanceof UserInterface) {
return;
}
$this->logger->alert('Debug hubspot: UserEntityListener postPersist');
$this->eventDispatcher->dispatch(
VopUserEvents::USER_CREATED,
new UserEvent($entity)
);
}
}
listeners.xml
<service id="vop_user.listener.user_entity" class="Vop\UserBundle\EventListener\UserEntityListener" autowire="true">
<tag name="doctrine.event_subscriber"/>
</service>
Event constant:
public const USER_CREATED = 'vop_user.event.user_created';
I got log
"Debug HubSpot: UserEntityListener postPersist"
But do not get this log in staging environment:
"Debug HubSpot: onUserCreated started"
On my machine, both logs are logged. What can be different in a staging environment? I do not see any errors also. How to debug? Adding logs inside Symfony dispatch call to see what inside breaks looks like a lot of work.
The exact version is 3.4.47
Jun 8, 2021 11:02 PM
Hi @cloudy-techi ,
Would you mind sharing a bit more details?
i.e) What are you trying to achieve?, What is the roadblock?, Which tools are you using? (HubSpot Report feature?) etc
Then I can see which Community members might be able to assist you here.