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

Update: get public url from provider #45

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
35 changes: 35 additions & 0 deletions Classes/Eel/Mautic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Garagist\Mautic\Eel;

use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\Flow\Annotations as Flow;
use Garagist\Mautic\Provider\DataProviderInterface;
use Neos\Eel\ProtectedContextAwareInterface;

class Mautic implements ProtectedContextAwareInterface
{
/**
* @Flow\Inject
* @var DataProviderInterface
*/
protected $data;

/**
* @param NodeInterface $node
* @return string
*/
public function getPublicUrl(NodeInterface $node): string
{
return $this->data->getPublicUrl($node);
}

/**
* @param string $methodName
* @return bool
*/
public function allowsCallOfMethod($methodName)
{
return true;
}
}
9 changes: 9 additions & 0 deletions Classes/Provider/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,13 @@ protected function filterHiddenSegments(array $segments): array
return !in_array($id, $hiddenSegments);
});
}

/**
* @param NodeInterface $node
* @return string
*/
public function getPublicUrl(NodeInterface $node): string
{
return $this->settings['publicUrl'];
}
}
2 changes: 2 additions & 0 deletions Classes/Provider/DataProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ public function filterSegments(MauticEmail $email, array $segmentsFromMautic): a
public function getPrefilledSegments(NodeInterface $node): array;

public function getCategoryNode(NodeInterface $node): ?NodeInterface;

public function getPublicUrl(NodeInterface $node): string;
}
3 changes: 3 additions & 0 deletions Configuration/Settings.Neos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Neos:
logFileURL: '%FLOW_PATH_DATA%Logs/Mautic.log'
createParentDirectories: true
severityThreshold: '%LOG_DEBUG%'
Fusion:
defaultContext:
Mautic: 'Garagist\Mautic\Eel\Mautic'
Neos:
userInterface:
translation:
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Fusion/Component/Form/Form.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ prototype(Garagist.Mautic:Component.Form) < prototype(Neos.Fusion:Component) {
}

id = ${q(node).property('mauticFormId')}
url = ${Configuration.Setting('Garagist.Mautic.publicUrl')}
url = ${Mautic.getPublicUrl(node)}
apiUrl = ${Configuration.Setting('Garagist.Mautic.api.baseUrl') || this.url}
embedType = ${Configuration.Setting('Garagist.Mautic.embedType')}
iframeClass = null
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Fusion/Component/TrackingCode.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ prototype(Garagist.Mautic:Component.TrackingCode) < prototype(Neos.Fusion:Compon
doNotTrack = ${PropTypes.boolean}
}

url = ${Configuration.setting('Garagist.Mautic.publicUrl')}
url = ${Mautic.getPublicUrl(node)}
enableTracking = ${Configuration.setting('Garagist.Mautic.enableTracking')}
doNotTrack = ${q(node).property('mauticDoNotTrack')}

Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Modules/Views/Index.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Garagist.Mautic.BackendController.index = Neos.Fusion:Component {
hasCategories = ${Carbon.Array.check(categories)}
showPagesWithoutEmails = ${this.hasPages && Array.some(pages, page => page.count > 0) ? 'false' : 'true'}
logo = ${ping ? 'Logo.svg' : 'LogoInactive.svg'}
mauticPublicUrl = ${Configuration.Setting('Garagist.Mautic.publicUrl')}
mauticPublicUrl = ${Mautic.getPublicUrl(node)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


_i18n = ${Translation.id('').package('Garagist.Mautic').source('Module')}

Expand Down