PHP code example of itk-dev / beskedfordeler-symfony
1. Go to this page and download the library: Download itk-dev/beskedfordeler-symfony library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
itk-dev / beskedfordeler-symfony example snippets
// config/bundles.php
return [
// …
Itkdev\BeskedfordelerBundle\ItkdevBeskedfordelerBundle::class => ['all' => true],
];
// src/EventSubscriber/BeskedfordelerEventSubscriber.php
namespace App\EventSubscriber;
use Itkdev\BeskedfordelerBundle\Event\PostStatusBeskedModtagEvent;
use Itkdev\BeskedfordelerBundle\Helper\MessageHelper;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class BeskedfordelerEventSubscriber implements EventSubscriberInterface
{
private MessageHelper $messageHelper;
public function __construct(private MessageHelper $messageHelper)
{
}
public static function getSubscribedEvents() {
return [
PostStatusBeskedModtagEvent::class => 'postStatusBeskedModtag',
];
}
public function postStatusBeskedModtag(PostStatusBeskedModtagEvent $event): void {
// Do something with the event.
try {
$data = $this->messageHelper->getBeskeddata($event->getDocument()->saveXML());
// …
} catch (\Throwable $exception) {
// Log the exception.
}
}
}