Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch recoverable error #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/RecipientSource/RecipientsRecipientSourceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Avisota\Contao\Core\Event\CreateRecipientSourceEvent;
use Avisota\Contao\Core\RecipientSource\RecipientSourceFactoryInterface;
use Avisota\Contao\Entity\RecipientSource;
use Avisota\RecipientSource\RecipientSourceInterface;
use ContaoCommunityAlliance\Contao\Bindings\ContaoEvents;
use ContaoCommunityAlliance\Contao\Bindings\Events\Controller\GenerateFrontendUrlEvent;
use ContaoCommunityAlliance\Contao\Bindings\Events\Controller\GetPageDetailsEvent;
Expand Down Expand Up @@ -57,13 +58,13 @@ public function createRecipientSource(RecipientSource $entity)
}

/**
* @param RecipientSource $entity
* @param RecipientsRecipientSource $recipientSource
* @param RecipientSource $entity
* @param RecipientSourceInterface $recipientSource
* @SuppressWarnings(PHPMD.LongVariable)
*/
protected function parseRecipientsManageSubscriptionPage(
RecipientSource $entity,
RecipientsRecipientSource &$recipientSource
RecipientSourceInterface &$recipientSource
) {
if (!$entity->getRecipientsManageSubscriptionPage()) {
return;
Expand All @@ -88,7 +89,9 @@ protected function parseRecipientsManageSubscriptionPage(
$url = rtrim(\Environment::get('base'), '/') . '/' . ltrim($url, '/');
}

$recipientSource->setManageSubscriptionUrlPattern($url);
if ($recipientSource instanceof RecipientsRecipientSource) {
$recipientSource->setManageSubscriptionUrlPattern($url);
}

$event = new CreateRecipientSourceEvent($entity, $recipientSource);
$eventDispatcher->dispatch(CoreEvents::CREATE_RECIPIENT_SOURCE, $event);
Expand All @@ -97,13 +100,13 @@ protected function parseRecipientsManageSubscriptionPage(
}

/**
* @param RecipientSource $entity
* @param RecipientsRecipientSource $recipientSource
* @param RecipientSource $entity
* @param RecipientSourceInterface $recipientSource
* @SuppressWarnings(PHPMD.LongVariable)
*/
protected function parseRecipientsUnsubscribePage(
RecipientSource $entity,
RecipientsRecipientSource &$recipientSource
RecipientSourceInterface &$recipientSource
) {
if (!$entity->getRecipientsUnsubscribePage()) {
return;
Expand All @@ -127,7 +130,9 @@ protected function parseRecipientsUnsubscribePage(
$url = rtrim(\Environment::get('base'), '/') . '/' . ltrim($url, '/');
}

$recipientSource->setUnsubscribeUrlPattern($url);
if ($recipientSource instanceof RecipientsRecipientSource) {
$recipientSource->setUnsubscribeUrlPattern($url);
}

$event = new CreateRecipientSourceEvent($entity, $recipientSource);
$eventDispatcher->dispatch(CoreEvents::CREATE_RECIPIENT_SOURCE, $event);
Expand Down