PHP code example of setono / sylius-plausible-plugin
1. Go to this page and download the library: Download setono/sylius-plausible-plugin 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/ */
declare(strict_types=1);
namespace App\Entity\Channel;
use Doctrine\ORM\Mapping as ORM;
use Setono\SyliusPlausiblePlugin\Model\ChannelInterface as PlausibleChannelInterface;
use Setono\SyliusPlausiblePlugin\Model\ChannelTrait as PlausibleChannelTrait;
use Sylius\Component\Core\Model\Channel as BaseChannel;
#[ORM\Entity]
#[ORM\Table(name: 'sylius_channel')]
class Channel extends BaseChannel implements PlausibleChannelInterface
{
use PlausibleChannelTrait;
}
use Psr\EventDispatcher\EventDispatcherInterface;
use Setono\SyliusPlausiblePlugin\Event\Plausible\Event;
final class NewsletterSignupHandler
{
public function __construct(private readonly EventDispatcherInterface $eventDispatcher)
{
}
public function __invoke(): void
{
$this->eventDispatcher->dispatch(
(new Event('Newsletter Signup'))->setProperty('source', 'footer'),
);
}
}
use Setono\SyliusPlausiblePlugin\Event\Plausible\Event;
use Setono\SyliusPlausiblePlugin\Event\Plausible\Events;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
#[AsEventListener(event: Event::class)]
final class AddCustomerGroupListener
{
public function __invoke(Event $event): void
{
if (Events::PURCHASE !== $event->getName()) {
return;
}
$event->setProperty('customer_group', 'wholesale');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.