<?php declare(strict_types=1);
namespace NetzpShopmanager6\Core\Content\Flow\Dispatching\Action;
use NetzpShopmanager6\Core\Framework\Event\MobilePushAware;
use Shopware\Core\Content\Flow\Dispatching\Action\FlowAction;
use Shopware\Core\Framework\Event\FlowEvent;
use NetzpShopmanager6\Components\PushMessageHelper;
class MobilePushAction extends FlowAction
{
private $pushHelper;
public function __construct(PushMessageHelper $pushHelper)
{
$this->pushHelper = $pushHelper;
}
public static function getName(): string
{
return 'action.netzp.mobilepush';
}
public static function getSubscribedEvents(): array
{
return [
self::getName() => 'handle',
];
}
public function requirements(): array
{
return [MobilePushAware::class];
}
public function handle(FlowEvent $event): void
{
$config = $event->getConfig();
if ( ! \array_key_exists('template', $config)) {
return;
}
$template = $config['template'];
if (empty($template)) {
return;
}
try {
$this->pushHelper->handlePushMessageForFlowBuilderEvent($event->getEvent(), $event->getContext(), $template);
}
catch (\Exception $ex) {
//
}
}
}