PHP code example of instride / opendxp-campaigns

1. Go to this page and download the library: Download instride/opendxp-campaigns 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/ */

    

instride / opendxp-campaigns example snippets


Instride\Bundle\OpenDxpCampaignsBundle\OpenDxpCampaignsBundle::class => ['all' => true],

class Customer extends Concrete implements NewsletterMemberInterface
{
    use NewsletterSubscriptionTrait;   // reads and writes the subscription fieldcollection
}

public function __construct(private readonly NewsletterManagerInterface $newsletter) {}

public function signUp(Customer $customer): void
{
    $this->newsletter->subscribe($customer, 'newsletter');
}

public function optOut(Customer $customer): void
{
    $this->newsletter->unsubscribe($customer, 'newsletter');
}

public function onStatusChanged(MemberSubscriptionStatusChangedEvent $event): void
{
    if ($event->getNewStatus() === SubscriptionStatus::UNSUBSCRIBED) {
        // …
    }
}