From e653edf5df77ad15a05579aecad0afd9081f8c9c Mon Sep 17 00:00:00 2001 From: Matic Zagmajster Date: Tue, 21 May 2024 12:23:26 +0000 Subject: [PATCH 1/4] Plugin activates on Mautic 5 --- Config/config.php | 5 ++--- Controller/MultidomainController.php | 2 +- Entity/Multidomain.php | 4 ++-- EventListener/MultidomianSubscriber.php | 14 +++++++------- MauticMultiDomainBundle.php | 2 +- Model/MultidomainModel.php | 16 ++++++++-------- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Config/config.php b/Config/config.php index ce976ad..9e74eed 100644 --- a/Config/config.php +++ b/Config/config.php @@ -46,13 +46,12 @@ 'arguments' => [ 'mautic.form.model.form', 'mautic.page.model.trackable', - 'mautic.helper.templating', + // 'templating', 'event_dispatcher', 'mautic.lead.model.field', 'mautic.tracker.contact', 'doctrine.orm.entity_manager', ], - //'public' => true, 'alias' => 'model.multidomain.multidomain' ], ], @@ -86,7 +85,7 @@ 'mautic.multidomain.subscriber.buildjssubscriber' => [ 'class' => \MauticPlugin\MauticMultiDomainBundle\EventListener\BuildJsSubscriber::class, 'arguments' => [ - 'templating.helper.assets', + \Mautic\CoreBundle\Twig\Helper\AssetsHelper::class, 'request_stack', 'router', ], diff --git a/Controller/MultidomainController.php b/Controller/MultidomainController.php index d5926eb..4cd794d 100644 --- a/Controller/MultidomainController.php +++ b/Controller/MultidomainController.php @@ -26,7 +26,7 @@ protected function getControllerBase() /** * @return string */ - protected function getModelName() + protected function getModelName(): string { return 'multidomain'; } diff --git a/Entity/Multidomain.php b/Entity/Multidomain.php index 96f83bb..92cda27 100644 --- a/Entity/Multidomain.php +++ b/Entity/Multidomain.php @@ -77,7 +77,7 @@ public static function loadValidatorMetadata(ClassMetadata $metadata) /** * @param ORM\ClassMetadata $metadata */ - public static function loadMetadata (ORM\ClassMetadata $metadata) + public static function loadMetadata (ORM\ClassMetadata $metadata): void { $builder = new ClassMetadataBuilder($metadata); @@ -102,7 +102,7 @@ public static function loadMetadata (ORM\ClassMetadata $metadata) * * @param $metadata */ - public static function loadApiMetadata(ApiMetadataDriver $metadata) + public static function loadApiMetadata(ApiMetadataDriver $metadata): void { $metadata->setGroupPrefix('multidomain') ->addListProperties( diff --git a/EventListener/MultidomianSubscriber.php b/EventListener/MultidomianSubscriber.php index dacdae4..c483723 100644 --- a/EventListener/MultidomianSubscriber.php +++ b/EventListener/MultidomianSubscriber.php @@ -26,7 +26,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\Routing\RouterInterface; @@ -98,19 +98,19 @@ public function __construct( public static function getSubscribedEvents() { return [ - KernelEvents::REQUEST => ['onKernelRequest', 0], - 'mautic.multidomain_post_save' => ['onMultidomainPostSave', 0], - 'mautic.multidomain_delete' => ['onMultidomainDelete', 0], - 'mautic.multidomain_replacement' => ['onTokenReplacement', 0], + KernelEvents::REQUEST => ['onKernelRequest', 0], + 'mautic.multidomain_post_save' => ['onMultidomainPostSave', 0], + 'mautic.multidomain_delete' => ['onMultidomainDelete', 0], + 'mautic.multidomain_replacement' => ['onTokenReplacement', 0], ]; } /* * Check and hijack the form's generate link if the ID has mf- in it */ - public function onKernelRequest(GetResponseEvent $event) + public function onKernelRequest(RequestEvent $event) { - if ($event->isMasterRequest()) { + if ($event->isMainRequest()) { // get the current event request $request = $event->getRequest(); $requestUri = $request->getRequestUri(); diff --git a/MauticMultiDomainBundle.php b/MauticMultiDomainBundle.php index 1dafee0..5f53e5b 100644 --- a/MauticMultiDomainBundle.php +++ b/MauticMultiDomainBundle.php @@ -11,7 +11,7 @@ */ class MauticMultiDomainBundle extends PluginBundleBase { - public static function onPluginInstall(Plugin $plugin, MauticFactory $factory, $metadata = null, $installedSchema = null) + public static function onPluginInstall(Plugin $plugin, MauticFactory $factory, $metadata = null, $installedSchema = null): void { if (null === $metadata) { $metadata = self::getMetadata($factory->getEntityManager()); diff --git a/Model/MultidomainModel.php b/Model/MultidomainModel.php index cacdb92..a4cfcc7 100644 --- a/Model/MultidomainModel.php +++ b/Model/MultidomainModel.php @@ -26,7 +26,8 @@ use MauticPlugin\MauticMultiDomainBundle\Event\MultidomainEvent; use MauticPlugin\MauticMultiDomainBundle\Form\Type\MultidomainType; use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; -use Symfony\Component\EventDispatcher\Event; +// use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; @@ -38,7 +39,7 @@ class MultidomainModel extends FormModel /** * @var ContainerAwareEventDispatcher */ - protected $dispatcher; + // protected $dispatcher; /** * @var \Mautic\FormBundle\Model\FormModel @@ -76,7 +77,6 @@ class MultidomainModel extends FormModel public function __construct( \Mautic\FormBundle\Model\FormModel $formModel, TrackableModel $trackableModel, - TemplatingHelper $templating, EventDispatcherInterface $dispatcher, FieldModel $leadFieldModel, ContactTracker $contactTracker, @@ -84,7 +84,7 @@ public function __construct( ) { $this->formModel = $formModel; $this->trackableModel = $trackableModel; - $this->templating = $templating; + // $this->templating = $templating; $this->dispatcher = $dispatcher; $this->leadFieldModel = $leadFieldModel; $this->contactTracker = $contactTracker; @@ -117,7 +117,7 @@ public function getPermissionBase() * * @throws NotFoundHttpException */ - public function createForm($entity, $formFactory, $action = null, $options = []) + public function createForm($entity, $formFactory, $action = null, $options = []): \Symfony\Component\Form\FormInterface { if (!$entity instanceof Multidomain) { throw new MethodNotAllowedHttpException(['Multidomain']); @@ -147,7 +147,7 @@ public function getRepository() * * @return Multidomain */ - public function getEntity($id = null) + public function getEntity($id = null): ?object { if (null === $id) { return new Multidomain(); @@ -162,7 +162,7 @@ public function getEntity($id = null) * @param Multidomain $entity * @param bool|false $unlock */ - public function saveEntity($entity, $unlock = true) + public function saveEntity($entity, $unlock = true): void { parent::saveEntity($entity, $unlock); $this->getRepository()->saveEntity($entity); @@ -196,7 +196,7 @@ public static function isLightColor($hex, $level = 200) * * @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException */ - protected function dispatchEvent($action, &$entity, $isNew = false, Event $event = null) + protected function dispatchEvent($action, &$entity, $isNew = false, Event $event = null): ?Event { if (!$entity instanceof Multidomain) { throw new MethodNotAllowedHttpException(['Multidomain']); From dc12fa24423634583c57f2d9ddcff02dadabc407 Mon Sep 17 00:00:00 2001 From: Matic Zagmajster Date: Tue, 21 May 2024 17:01:29 +0000 Subject: [PATCH 2/4] Make GUI working again --- Config/config.php | 30 +------ Config/services.php | 35 ++++++++ Controller/MultidomainController.php | 37 ++++---- .../MauticMultiDomainExtension.php | 22 +++++ EventListener/BuildJsSubscriber.php | 3 +- EventListener/BuilderSubscriber.php | 3 +- Form/Type/MultidomainType.php | 2 +- Model/MultidomainModel.php | 58 ++++++++++-- .../views}/Multidomain/details.html.php | 0 Resources/views/Multidomain/details.html.twig | 59 ++++++++++++ .../views}/Multidomain/form.html.php | 0 Resources/views/Multidomain/form.html.twig | 47 ++++++++++ .../views}/Multidomain/index.html.php | 0 Resources/views/Multidomain/index.html.twig | 39 ++++++++ .../views}/Multidomain/list.html.php | 0 Resources/views/Multidomain/list.html.twig | 89 +++++++++++++++++++ 16 files changed, 370 insertions(+), 54 deletions(-) create mode 100644 Config/services.php create mode 100644 DependencyInjection/MauticMultiDomainExtension.php rename {Views => Resources/views}/Multidomain/details.html.php (100%) create mode 100644 Resources/views/Multidomain/details.html.twig rename {Views => Resources/views}/Multidomain/form.html.php (100%) create mode 100644 Resources/views/Multidomain/form.html.twig rename {Views => Resources/views}/Multidomain/index.html.php (100%) create mode 100644 Resources/views/Multidomain/index.html.twig rename {Views => Resources/views}/Multidomain/list.html.php (100%) create mode 100644 Resources/views/Multidomain/list.html.twig diff --git a/Config/config.php b/Config/config.php index 9e74eed..dc673d6 100644 --- a/Config/config.php +++ b/Config/config.php @@ -9,11 +9,11 @@ 'main' => [ 'mautic_multidomain_index' => [ 'path' => '/multidomain/{page}', - 'controller' => 'MauticMultiDomainBundle:Multidomain:index', + 'controller' => 'MauticPlugin\MauticMultiDomainBundle\Controller\MultidomainController:indexAction', ], 'mautic_multidomain_action' => [ 'path' => '/multidomain/{objectAction}/{objectId}', - 'controller' => 'MauticMultiDomainBundle:Multidomain:execute', + 'controller' => 'MauticPlugin\MauticMultiDomainBundle\Controller\MultidomainController:executeAction', ], ], 'api' => [ @@ -21,7 +21,7 @@ 'standard_entity' => true, 'name' => 'multidomain', 'path' => '/multidomain', - 'controller' => 'MauticMultiDomainBundle:Api\MultidomainApi', + 'controller' => 'MauticPlugin\MauticMultiDomainBundle\Controller\Api\MultidomainApiController', ], ], ], @@ -40,21 +40,7 @@ 'class' => \MauticPlugin\MauticMultiDomainBundle\Form\Type\MultidomainType::class, ], ], - 'models' => [ - 'mautic.multidomain.model.multidomain' => [ - 'class' => \MauticPlugin\MauticMultiDomainBundle\Model\MultidomainModel::class, - 'arguments' => [ - 'mautic.form.model.form', - 'mautic.page.model.trackable', - // 'templating', - 'event_dispatcher', - 'mautic.lead.model.field', - 'mautic.tracker.contact', - 'doctrine.orm.entity_manager', - ], - 'alias' => 'model.multidomain.multidomain' - ], - ], + 'models' => [], 'events' => [ 'mautic.multidomain.subscriber.multidomain' => [ 'class' => \MauticPlugin\MauticMultiDomainBundle\EventListener\MultidomianSubscriber::class, @@ -82,14 +68,6 @@ 'router', ], ], - 'mautic.multidomain.subscriber.buildjssubscriber' => [ - 'class' => \MauticPlugin\MauticMultiDomainBundle\EventListener\BuildJsSubscriber::class, - 'arguments' => [ - \Mautic\CoreBundle\Twig\Helper\AssetsHelper::class, - 'request_stack', - 'router', - ], - ], ], ], ]; diff --git a/Config/services.php b/Config/services.php new file mode 100644 index 0000000..932ca1b --- /dev/null +++ b/Config/services.php @@ -0,0 +1,35 @@ +services() + ->defaults() + ->autowire() + ->autoconfigure() + ->public(); + + $excludes = [ + 'Permissions', + ]; + + $services->load( + 'MauticPlugin\\MauticMultiDomainBundle\\', + __DIR__.'/../' + ) + ->exclude('../{'.implode(',', array_merge(MauticCoreExtension::DEFAULT_EXCLUDES, $excludes)).'}'); + + $services->load( + 'MauticPlugin\\MauticMultiDomainBundle\\Entity\\', + __DIR__.'/../Entity/*Repository.php' + ); + + $services->alias( + 'mautic.multidomain.model.multidomain', + \MauticPlugin\MauticMultiDomainBundle\Model\MultidomainModel::class + ); + +}; diff --git a/Controller/MultidomainController.php b/Controller/MultidomainController.php index 4cd794d..4af2991 100644 --- a/Controller/MultidomainController.php +++ b/Controller/MultidomainController.php @@ -18,10 +18,10 @@ class MultidomainController extends AbstractStandardFormController /** * @return string */ - protected function getControllerBase() + /*protected function getControllerBase() { return 'MauticMultiDomainBundle:Multidomain'; - } + }*/ /** * @return string @@ -31,6 +31,11 @@ protected function getModelName(): string return 'multidomain'; } + protected function getTemplateBase() + { + return '@MauticMultiDomain/Multidomain'; + } + /** * @return string */ @@ -44,9 +49,9 @@ protected function getDefaultOrderColumn() * * @return JsonResponse|RedirectResponse|Response */ - public function indexAction($page = 1) + public function indexAction(Request $request, $page = 1) { - return parent::indexStandard($page); + return parent::indexStandard($request, $page); } /** @@ -54,9 +59,9 @@ public function indexAction($page = 1) * * @return JsonResponse|Response */ - public function newAction() + public function newAction(Request $request) { - return parent::newStandard(); + return parent::newStandard($request); } /** @@ -67,9 +72,9 @@ public function newAction() * * @return JsonResponse|Response */ - public function editAction($objectId, $ignorePost = false) + public function editAction(Request $request, $objectId, $ignorePost = false) { - return parent::editStandard($objectId, $ignorePost); + return parent::editStandard($request, $objectId, $ignorePost); } /** @@ -79,9 +84,9 @@ public function editAction($objectId, $ignorePost = false) * * @return array|JsonResponse|RedirectResponse|Response */ - public function viewAction($objectId) + public function viewAction(Request $request, $objectId) { - return parent::viewStandard($objectId, 'maultidomain', 'plugin.maultidomain'); + return parent::viewStandard($request, $objectId, 'maultidomain', 'plugin.maultidomain'); } /** @@ -91,9 +96,9 @@ public function viewAction($objectId) * * @return JsonResponse|RedirectResponse|Response */ - public function cloneAction($objectId) + public function cloneAction(Request $request, $objectId) { - return parent::cloneStandard($objectId); + return parent::cloneStandard($request, $objectId); } /** @@ -103,9 +108,9 @@ public function cloneAction($objectId) * * @return JsonResponse|RedirectResponse */ - public function deleteAction($objectId) + public function deleteAction(Request $request, $objectId) { - return parent::deleteStandard($objectId); + return parent::deleteStandard($request, $objectId); } /** @@ -113,9 +118,9 @@ public function deleteAction($objectId) * * @return JsonResponse|RedirectResponse */ - public function batchDeleteAction() + public function batchDeleteAction(Request $request) { - return parent::batchDeleteStandard(); + return parent::batchDeleteStandard($request); } diff --git a/DependencyInjection/MauticMultiDomainExtension.php b/DependencyInjection/MauticMultiDomainExtension.php new file mode 100644 index 0000000..d00d06b --- /dev/null +++ b/DependencyInjection/MauticMultiDomainExtension.php @@ -0,0 +1,22 @@ +load('services.php'); + } +} diff --git a/EventListener/BuildJsSubscriber.php b/EventListener/BuildJsSubscriber.php index c38442f..038e6d1 100644 --- a/EventListener/BuildJsSubscriber.php +++ b/EventListener/BuildJsSubscriber.php @@ -4,7 +4,8 @@ use Mautic\CoreBundle\CoreEvents; use Mautic\CoreBundle\Event\BuildJsEvent; -use Mautic\CoreBundle\Templating\Helper\AssetsHelper; +use Mautic\CoreBundle\Twig\Helper\AssetsHelper; +//use Mautic\CoreBundle\Templating\Helper\AssetsHelper; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Routing\RouterInterface; diff --git a/EventListener/BuilderSubscriber.php b/EventListener/BuilderSubscriber.php index 0dccc17..cbc0fac 100644 --- a/EventListener/BuilderSubscriber.php +++ b/EventListener/BuilderSubscriber.php @@ -32,7 +32,8 @@ use Mautic\PageBundle\Model\RedirectModel; use Mautic\PageBundle\Model\TrackableModel; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Translation\TranslatorInterface; +// use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; use MauticPlugin\MauticMultiDomainBundle\Model\MultidomainModel; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; diff --git a/Form/Type/MultidomainType.php b/Form/Type/MultidomainType.php index 00e12c0..30c0426 100644 --- a/Form/Type/MultidomainType.php +++ b/Form/Type/MultidomainType.php @@ -42,7 +42,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) /** * {@inheritdoc} */ - public function getBlockPrefix() + public function getBlockPrefix(): string { return 'multidomain_type'; } diff --git a/Model/MultidomainModel.php b/Model/MultidomainModel.php index a4cfcc7..db5f031 100644 --- a/Model/MultidomainModel.php +++ b/Model/MultidomainModel.php @@ -13,11 +13,16 @@ use Doctrine\DBAL\Query\QueryBuilder; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use Mautic\CoreBundle\Event\TokenReplacementEvent; use Mautic\CoreBundle\Helper\Chart\ChartQuery; use Mautic\CoreBundle\Helper\Chart\LineChart; use Mautic\CoreBundle\Helper\TemplatingHelper; +use Mautic\CoreBundle\Helper\CoreParametersHelper; +use Mautic\CoreBundle\Helper\UserHelper; use Mautic\CoreBundle\Model\FormModel; +use Mautic\CoreBundle\Security\Permissions\CorePermissions; +use Mautic\CoreBundle\Translation\Translator; use Mautic\LeadBundle\Entity\Lead; use Mautic\LeadBundle\Model\FieldModel; use Mautic\LeadBundle\Tracker\ContactTracker; @@ -25,14 +30,16 @@ use MauticPlugin\MauticMultiDomainBundle\Entity\Multidomain; use MauticPlugin\MauticMultiDomainBundle\Event\MultidomainEvent; use MauticPlugin\MauticMultiDomainBundle\Form\Type\MultidomainType; +use Psr\Log\LoggerInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; -// use Symfony\Component\EventDispatcher\Event; -use Symfony\Contracts\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Contracts\EventDispatcher\Event; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; + class MultidomainModel extends FormModel { @@ -70,11 +77,44 @@ class MultidomainModel extends FormModel * * @var EntityManager $entityManager */ - private static $entityManager; + // private static $entityManager; + + public function __construct( + EntityManagerInterface $em, + CorePermissions $security, + EventDispatcherInterface $dispatcher, + UrlGeneratorInterface $router, + Translator $translator, + UserHelper $userHelper, + LoggerInterface $logger, + CoreParametersHelper $coreParametersHelper, + \Mautic\FormBundle\Model\FormModel $formModel, + TrackableModel $trackableModel, + FieldModel $leadFieldModel, + ContactTracker $contactTracker + ) + { + parent::__construct( + $em, + $security, + $dispatcher, + $router, + $translator, + $userHelper, + $logger, + $coreParametersHelper + ); + + $this->formModel = $formModel; + $this->trackableModel = $trackableModel; + $this->leadFieldModel = $leadFieldModel; + $this->contactTracker = $contactTracker; + } + /** * MultidomainModel constructor. */ - public function __construct( + /*public function __construct( \Mautic\FormBundle\Model\FormModel $formModel, TrackableModel $trackableModel, EventDispatcherInterface $dispatcher, @@ -88,8 +128,8 @@ public function __construct( $this->dispatcher = $dispatcher; $this->leadFieldModel = $leadFieldModel; $this->contactTracker = $contactTracker; - static::$entityManager = $entityManager; - } + + }*/ /** * @return string @@ -225,7 +265,7 @@ protected function dispatchEvent($action, &$entity, $isNew = false, Event $event $event->setEntityManager($this->em); } - $this->dispatcher->dispatch($name, $event); + $this->dispatcher->dispatch($event, $name); return $event; } else { diff --git a/Views/Multidomain/details.html.php b/Resources/views/Multidomain/details.html.php similarity index 100% rename from Views/Multidomain/details.html.php rename to Resources/views/Multidomain/details.html.php diff --git a/Resources/views/Multidomain/details.html.twig b/Resources/views/Multidomain/details.html.twig new file mode 100644 index 0000000..e5a6165 --- /dev/null +++ b/Resources/views/Multidomain/details.html.twig @@ -0,0 +1,59 @@ +{% extends '@MauticCore/Default/content.html.twig' %} + +{% set mauticContent = 'multidomain' %} +{% set headerTitle = item.getEmail() %} + +{% block mauticContent %} + {{ mauticContent }} +{% endblock %} + +{% block headerTitle %} + {{ headerTitle }} +{% endblock %} + +{% block actions %} + {{ include('@MauticCore/Helper/page_actions.html.twig', { + 'item': item, + 'templateButtons': { + 'edit': securityHasEntityAccess( + permissions['multidomain:items:editown'], + permissions['multidomain:items:editother'], + item.getCreatedBy() + ), + 'clone': permissions['multidomain:items:create'], + 'delete': securityHasEntityAccess( + permissions['multidomain:items:deleteown'], + permissions['multidomain:items:deleteother'], + item.getCreatedBy() + ), + 'close': securityIsGranted('multidomain:items:view') + }, + 'routeBase': 'multidomain', + 'langVar': 'multidomain' + }) }} +{% endblock %} + +{% block content %} + +
+ +
+
+
+ {{ 'plugin.multidomain.email'|trans }}: +
+
+ {{ item.getEmail() }} +
+
+
+
+ {{ 'plugin.multidomain.domain'|trans }}: +
+
+

{{ item.getDomain() }}

+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/Views/Multidomain/form.html.php b/Resources/views/Multidomain/form.html.php similarity index 100% rename from Views/Multidomain/form.html.php rename to Resources/views/Multidomain/form.html.php diff --git a/Resources/views/Multidomain/form.html.twig b/Resources/views/Multidomain/form.html.twig new file mode 100644 index 0000000..d121264 --- /dev/null +++ b/Resources/views/Multidomain/form.html.twig @@ -0,0 +1,47 @@ +{% extends '@MauticCore/Default/content.html.twig' %} + +{% block mauticContent %} + multidomain +{% endblock %} + +{% set header = entity.getId() + ? 'mautic.multidomain.edit'|trans({'%title%': entity.getEmail()|trans}) + : 'mautic.multidomain.new'|trans +%} +{% block headerTitle %} + {{ header }} +{% endblock %} + + + +{% block content %} + +{{ form_start(form) }} + + +
+ +
+ +
+

+ {{ 'mautic.multidomain.add.warning'|trans }} +

+
+
+
+ {{ form_row(form.email) }} +
+
+
+
+ {{ form_row(form.domain) }} +
+
+
+
+ + +{{ form_end(form) }} +{% endblock %} \ No newline at end of file diff --git a/Views/Multidomain/index.html.php b/Resources/views/Multidomain/index.html.php similarity index 100% rename from Views/Multidomain/index.html.php rename to Resources/views/Multidomain/index.html.php diff --git a/Resources/views/Multidomain/index.html.twig b/Resources/views/Multidomain/index.html.twig new file mode 100644 index 0000000..152537c --- /dev/null +++ b/Resources/views/Multidomain/index.html.twig @@ -0,0 +1,39 @@ +{# + * @copyright 2016 Mautic, Inc. All rights reserved + * @author Mautic, Inc + * + * @link https://mautic.org + * + * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html +#} +{% extends '@MauticCore/Default/content.html.twig' %} + +{% block mauticContent %} + multidomain +{% endblock %} + +{% block headerTitle %} + {{ 'mautic.multidomain.title'|trans }} +{% endblock %} + +{% block actions %} + {{ include('@MauticCore/Helper/page_actions.html.twig', { + 'templateButtons': { + 'new': permissions['multidomain:items:create'] + }, + 'routeBase': 'multidomain' + }) }} +{% endblock %} + +{% block content %} +
+ {{ include('@MauticCore/Helper/list_toolbar.html.twig', { + 'searchValue': searchValue, + 'searchHelp': 'mautic.core.help.searchcommands', + 'action': currentRoute + }) }} +
+ {{ block('_content') }} +
+
+{% endblock %} \ No newline at end of file diff --git a/Views/Multidomain/list.html.php b/Resources/views/Multidomain/list.html.php similarity index 100% rename from Views/Multidomain/list.html.php rename to Resources/views/Multidomain/list.html.php diff --git a/Resources/views/Multidomain/list.html.twig b/Resources/views/Multidomain/list.html.twig new file mode 100644 index 0000000..ea6c779 --- /dev/null +++ b/Resources/views/Multidomain/list.html.twig @@ -0,0 +1,89 @@ +{# + * @copyright 2016 Mautic, Inc. All rights reserved + * @author Mautic, Inc + * + * @link https://mautic.org + * + * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html +#} + +{% set isIndex = 'index' == tmpl ? true : false %} +{% set tmpl = 'list' %} +{% extends isIndex ? '@MauticMultiDomain/Multidomain/index.html.twig' : 'MauticCore/Default/raw_output.html.twig' %} + +{% block content %} +{% if items|length %} +
+ + + + {{ include('@MauticCore/Helper/tableheader.html.twig', { + 'checkall': 'true', + 'target': '#multidomainTable', + 'routeBase': 'multidomain', + 'templateButtons': { + 'delete': permissions['multidomain:items:delete'] + } + }) }} + {{ include('@MauticCore/Helper/tableheader.html.twig', { + 'sessionVar': 'multidomain', + 'orderBy': 'f.email', + 'text': 'plugin.multidomain.email', + 'class': 'col-multidomain-name', + 'default': true + }) }} + + + + {% for item in items %} + + + + + {% endfor %} + +
+ {{ include('@MauticCore/Helper/list_actions.html.twig', { + 'item': item, + 'templateButtons': { + 'edit': securityHasEntityAccess( + permissions['multidomain:items:editown'], + permissions['multidomain:items:editother'], + item.getCreatedBy() + ), + 'clone': permissions['multidomain:items:create'], + 'delete': securityHasEntityAccess( + permissions['multidomain:items:deleteown'], + permissions['multidomain:items:deleteother'], + item.getCreatedBy() + ) + }, + 'routeBase': 'multidomain' + }) }} + +
+ {# {{ include('MauticCore:Helper:publishstatus_icon.html.twig', {'item': item, 'model': 'multidomain'}) }} #} + + {{ item.getEmail() }} + +
+ {% if item.getDomain() %} +
+ {{ item.getDomain() }} +
+ {% endif %} +
+
+ +{% else %} + {{ include('@MauticCore/Helper/noresults.html.twig', {'tip': 'mautic.multidomain.noresults.tip'}) }} +{% endif %} +{% endblock %} From 3c429c3a7ab402d8300a52d035c5ff471c20e41a Mon Sep 17 00:00:00 2001 From: Matic Zagmajster Date: Tue, 21 May 2024 17:07:25 +0000 Subject: [PATCH 3/4] Cleanup & CS fix --- Config/config.php | 12 +- Config/services.php | 1 - Controller/Api/MultidomainApiController.php | 4 +- Controller/MultidomainController.php | 23 +--- Entity/Multidomain.php | 33 ++---- Entity/MultidomainRepository.php | 8 +- Event/MultidomainEvent.php | 8 -- EventListener/BuildJsSubscriber.php | 4 +- EventListener/BuilderSubscriber.php | 83 +++++-------- EventListener/MultidomianSubscriber.php | 27 ++--- Form/Type/MultidomainType.php | 34 +++--- MauticMultiDomainBundle.php | 2 +- Model/MultidomainModel.php | 96 ++++++--------- Permissions/MultidomainPermissions.php | 8 -- .../Security/MultiDomainPermissions.php | 11 +- Resources/views/Multidomain/details.html.php | 58 ---------- Resources/views/Multidomain/form.html.php | 49 -------- Resources/views/Multidomain/index.html.php | 42 ------- Resources/views/Multidomain/list.html.php | 109 ------------------ 19 files changed, 118 insertions(+), 494 deletions(-) delete mode 100644 Resources/views/Multidomain/details.html.php delete mode 100644 Resources/views/Multidomain/form.html.php delete mode 100644 Resources/views/Multidomain/index.html.php delete mode 100644 Resources/views/Multidomain/list.html.php diff --git a/Config/config.php b/Config/config.php index dc673d6..c622d26 100644 --- a/Config/config.php +++ b/Config/config.php @@ -5,7 +5,7 @@ 'description' => 'User can add multiple tracking domains for emails.', 'author' => 'Abdullah Kiser / Friendly Automate', 'version' => '1.0.1', - 'routes' => [ + 'routes' => [ 'main' => [ 'mautic_multidomain_index' => [ 'path' => '/multidomain/{page}', @@ -19,17 +19,17 @@ 'api' => [ 'mautic_api_multidomainstandard' => [ 'standard_entity' => true, - 'name' => 'multidomain', - 'path' => '/multidomain', - 'controller' => 'MauticPlugin\MauticMultiDomainBundle\Controller\Api\MultidomainApiController', + 'name' => 'multidomain', + 'path' => '/multidomain', + 'controller' => 'MauticPlugin\MauticMultiDomainBundle\Controller\Api\MultidomainApiController', ], ], ], 'menu' => [ 'main' => [ 'mautic.multidomain.menu' => [ - 'route' => 'mautic_multidomain_index', - 'priority' => 10, + 'route' => 'mautic_multidomain_index', + 'priority' => 10, 'iconClass' => 'fa-globe', ], ], diff --git a/Config/services.php b/Config/services.php index 932ca1b..f7a39dc 100644 --- a/Config/services.php +++ b/Config/services.php @@ -31,5 +31,4 @@ 'mautic.multidomain.model.multidomain', \MauticPlugin\MauticMultiDomainBundle\Model\MultidomainModel::class ); - }; diff --git a/Controller/Api/MultidomainApiController.php b/Controller/Api/MultidomainApiController.php index 7e17469..76e1963 100644 --- a/Controller/Api/MultidomainApiController.php +++ b/Controller/Api/MultidomainApiController.php @@ -3,8 +3,8 @@ namespace MauticPlugin\MauticMultiDomainBundle\Controller\Api; use Mautic\ApiBundle\Controller\CommonApiController; -use Symfony\Component\HttpKernel\Event\FilterControllerEvent; use MauticPlugin\MauticMultiDomainBundle\Entity\Multidomain; +use Symfony\Component\HttpKernel\Event\FilterControllerEvent; /** * Class MultidomainApiController. @@ -24,4 +24,4 @@ public function initialize(FilterControllerEvent $event) parent::initialize($event); } -} \ No newline at end of file +} diff --git a/Controller/MultidomainController.php b/Controller/MultidomainController.php index 4af2991..f5ec091 100644 --- a/Controller/MultidomainController.php +++ b/Controller/MultidomainController.php @@ -3,29 +3,16 @@ namespace MauticPlugin\MauticMultiDomainBundle\Controller; use Mautic\CoreBundle\Controller\AbstractStandardFormController; -use Mautic\CoreBundle\Form\Type\DateRangeType; -use MauticPlugin\MauticSpintaxBundle\Model\EmailVariation; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; /** * Class MultidomainController. */ class MultidomainController extends AbstractStandardFormController { - /** - * @return string - */ - /*protected function getControllerBase() - { - return 'MauticMultiDomainBundle:Multidomain'; - }*/ - - /** - * @return string - */ protected function getModelName(): string { return 'multidomain'; @@ -75,13 +62,11 @@ public function newAction(Request $request) public function editAction(Request $request, $objectId, $ignorePost = false) { return parent::editStandard($request, $objectId, $ignorePost); - } + } /** * Displays details on a spintax. * - * @param $objectId - * * @return array|JsonResponse|RedirectResponse|Response */ public function viewAction(Request $request, $objectId) @@ -122,6 +107,4 @@ public function batchDeleteAction(Request $request) { return parent::batchDeleteStandard($request); } - - -} \ No newline at end of file +} diff --git a/Entity/Multidomain.php b/Entity/Multidomain.php index 92cda27..5981e13 100644 --- a/Entity/Multidomain.php +++ b/Entity/Multidomain.php @@ -4,18 +4,15 @@ use Doctrine\ORM\Mapping as ORM; use Mautic\ApiBundle\Serializer\Driver\ApiMetadataDriver; -use Symfony\Component\Validator\Constraints as Assert; -use Symfony\Component\Validator\Mapping\ClassMetadata; -use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -use Mautic\CategoryBundle\Entity\Category; use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder; use Mautic\CoreBundle\Entity\FormEntity; -use Mautic\FormBundle\Entity\Form; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; +use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Validator\Mapping\ClassMetadata; /** * This class processes payment requests from Webpayment - * Class Multidomain - * @package MauticPlugin\MauticMultiDomainBundle\Entity + * Class Multidomain. */ class Multidomain extends FormEntity { @@ -25,7 +22,6 @@ class Multidomain extends FormEntity private $id; /** - * * @var string */ private $email; @@ -37,7 +33,6 @@ class Multidomain extends FormEntity public static function loadValidatorMetadata(ClassMetadata $metadata) { - $metadata->addConstraint(new UniqueEntity([ 'fields' => 'email', ])); @@ -74,10 +69,7 @@ public static function loadValidatorMetadata(ClassMetadata $metadata) ); } - /** - * @param ORM\ClassMetadata $metadata - */ - public static function loadMetadata (ORM\ClassMetadata $metadata): void + public static function loadMetadata(ORM\ClassMetadata $metadata): void { $builder = new ClassMetadataBuilder($metadata); @@ -86,7 +78,7 @@ public static function loadMetadata (ORM\ClassMetadata $metadata): void // Helper functions $builder->addId(); - + $builder->createField('email', 'string') ->columnName('email') ->build(); @@ -94,13 +86,10 @@ public static function loadMetadata (ORM\ClassMetadata $metadata): void $builder->createField('domain', 'text') ->columnName('domain') ->build(); - } /** * Prepares the metadata for API usage. - * - * @param $metadata */ public static function loadApiMetadata(ApiMetadataDriver $metadata): void { @@ -131,6 +120,7 @@ public function getEmail(): ?string public function setEmail(string $email): Multidomain { $this->email = $email; + return $this; } @@ -142,11 +132,12 @@ public function getDomain(): ?string public function setDomain(string $text): Multidomain { $this->domain = $text; + return $this; } /** - * Get Fake name to be compatable with getName of commonEntity. + * Get Fake name to be compatable with getName of commonEntity. */ public function getName() { @@ -154,12 +145,12 @@ public function getName() } /** - * Set Fake name to be compatable with getName of commonEntity. - * + * Set Fake name to be compatable with getName of commonEntity. */ public function setName(string $email): Multidomain { $this->email = $email; + return $this; } -} \ No newline at end of file +} diff --git a/Entity/MultidomainRepository.php b/Entity/MultidomainRepository.php index 3b4f7ca..16b33ed 100644 --- a/Entity/MultidomainRepository.php +++ b/Entity/MultidomainRepository.php @@ -5,7 +5,7 @@ use Mautic\CoreBundle\Entity\CommonRepository; /** - * MultidomainRepository + * MultidomainRepository. */ class MultidomainRepository extends CommonRepository { @@ -15,8 +15,8 @@ public function getByPublished($isPublished = true) $q->select('md') ->from(Multidomain::class, 'md') ->where('md.isPublished = :isPublished') - ->setParameters(['isPublished' => $isPublished]) - ; + ->setParameters(['isPublished' => $isPublished]); + return $q->getQuery()->getResult(); } -} \ No newline at end of file +} diff --git a/Event/MultidomainEvent.php b/Event/MultidomainEvent.php index a735244..1ec76ec 100644 --- a/Event/MultidomainEvent.php +++ b/Event/MultidomainEvent.php @@ -1,13 +1,5 @@ [ ['onEmailGenerate', 0], // Ensure this is done last in order to catch all tokenized URLs @@ -120,14 +101,14 @@ public static function getSubscribedEvents() } public function onEmailGenerate(EmailSendEvent $event) - { - $idHash = $event->getIdHash(); - $lead = $event->getLead(); - $email = $event->getEmail(); - $senderEmail = null; + { + $idHash = $event->getIdHash(); + $lead = $event->getLead(); + $email = $event->getEmail(); + $senderEmail = null; $senderDomain = null; - if(!$email instanceof Email){ + if (!$email instanceof Email) { return; } @@ -135,34 +116,34 @@ public function onEmailGenerate(EmailSendEvent $event) // Generate a bogus idHash to prevent errors for routes that may include it $idHash = uniqid(); } - + $unsubscribeText = $this->coreParametersHelper->get('unsubscribe_text'); - $webviewText = $this->coreParametersHelper->get('webview_text'); - + $webviewText = $this->coreParametersHelper->get('webview_text'); + // Check if the Mailer is Owner is set, if not then search the sender email from Email channels From address // And finally if nothing is set, use the mailer from email if it is not blank. - $senderEmail = $this->coreParametersHelper->get("mailer_from_email"); + $senderEmail = $this->coreParametersHelper->get('mailer_from_email'); $mailerIsOwnerGlobal = $this->coreParametersHelper->get('mailer_is_owner'); $mailerIsOwner = $email->getUseOwnerAsMailer(); - if(($mailerIsOwnerGlobal || $mailerIsOwner) && $lead['id']){ + if (($mailerIsOwnerGlobal || $mailerIsOwner) && $lead['id']) { $ownerEmail = $event->getTokens()['{ownerfield=email}'] ?? null; if (!empty($ownerEmail)) { $senderEmail = $ownerEmail; } } - if(empty($ownerEmail) && $email && $email->getFromAddress()){ + if (empty($ownerEmail) && $email && $email->getFromAddress()) { $senderEmail = $email->getFromAddress(); } - if($senderEmail){ + if ($senderEmail) { // Get the Domain from the MultiDomain Configuration by email. $multiDomian = $this->multidomainModel->getRepository()->findOneBy(['email' => $senderEmail]); - if($multiDomian){ + if ($multiDomian) { $senderDomain = $multiDomian->getDomain(); } } - + if (!$unsubscribeText) { $unsubscribeText = $this->translator->trans('mautic.email.unsubscribe.text', ['%link%' => '|URL|']); } @@ -171,7 +152,6 @@ public function onEmailGenerate(EmailSendEvent $event) $event->addToken('{unsubscribe_url}', $this->buildUrl('mautic_email_unsubscribe', ['idHash' => $idHash], true, [], [], $senderDomain)); - if (!$webviewText) { $webviewText = $this->translator->trans('mautic.email.webview.text', ['%link%' => '|URL|']); } @@ -230,8 +210,6 @@ public function convertUrlsToTokens(EmailSendEvent $event) /** * Parses content for URLs and tokens. * - * @param $emailId - * * @return mixed */ private function parseContentForUrls(EmailSendEvent $event, $emailId) @@ -275,26 +253,23 @@ private function parseContentForUrls(EmailSendEvent $event, $emailId) } private function buildUrl( - $route, - $routeParams = [], - $absolute = true, - $clickthrough = [], - $utmTags = [], + $route, + $routeParams = [], + $absolute = true, + $clickthrough = [], + $utmTags = [], $domain = null - ) - { - - - if($domain){ + ) { + if ($domain) { $parseUrl = parse_url($domain); - $context = $this->router->getGenerator()->getContext(); + $context = $this->router->getGenerator()->getContext(); $context->setHost($parseUrl['host']); $context->setScheme($parseUrl['scheme']); } - $referenceType = ($absolute) ? UrlGeneratorInterface::ABSOLUTE_URL : UrlGeneratorInterface::ABSOLUTE_PATH; + $referenceType = ($absolute) ? UrlGeneratorInterface::ABSOLUTE_URL : UrlGeneratorInterface::ABSOLUTE_PATH; $url = $this->router->generate($route, $routeParams, $referenceType); - + return $url.((!empty($clickthrough)) ? '?ct='.$this->encodeArrayForUrl($clickthrough) : ''); } } diff --git a/EventListener/MultidomianSubscriber.php b/EventListener/MultidomianSubscriber.php index c483723..51d07a9 100644 --- a/EventListener/MultidomianSubscriber.php +++ b/EventListener/MultidomianSubscriber.php @@ -1,13 +1,5 @@ router = $router; - $this->ipHelper = $ipLookupHelper; - $this->auditLogModel = $auditLogModel; - $this->trackableModel = $trackableModel; - $this->pageTokenHelper = $pageTokenHelper; - $this->assetTokenHelper = $assetTokenHelper; + $this->router = $router; + $this->ipHelper = $ipLookupHelper; + $this->auditLogModel = $auditLogModel; + $this->trackableModel = $trackableModel; + $this->pageTokenHelper = $pageTokenHelper; + $this->assetTokenHelper = $assetTokenHelper; $this->multidomainModel = $multidomainModel; - $this->requestStack = $requestStack; + $this->requestStack = $requestStack; } /** @@ -120,7 +112,7 @@ public function onKernelRequest(RequestEvent $event) if (false !== strpos($requestUri, $formGenerateUrl)) { $id = InputHelper::_($this->requestStack->getCurrentRequest()->get('id')); if (0 === strpos($id, 'mf-')) { - $mfId = str_replace('mf-', '', $id); + $mfId = str_replace('mf-', '', $id); $multidomainGenerateUrl = $this->router->generate('mautic_multidomain_action', ['id' => $mfId]); $event->setResponse(new RedirectResponse($multidomainGenerateUrl)); @@ -144,9 +136,8 @@ public function onMultidomainPostSave(MultidomainEvent $event) 'details' => $details, 'ipAddress' => $this->ipHelper->getIpAddressFromRequest(), ]; - + $this->auditLogModel->writeToLog($log); - } } diff --git a/Form/Type/MultidomainType.php b/Form/Type/MultidomainType.php index 30c0426..76b54ee 100644 --- a/Form/Type/MultidomainType.php +++ b/Form/Type/MultidomainType.php @@ -2,43 +2,37 @@ namespace MauticPlugin\MauticMultiDomainBundle\Form\Type; +use Mautic\CoreBundle\Form\Type\FormButtonsType; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\Extension\Core\Type\SubmitType; -use Mautic\CoreBundle\Form\Type\FormButtonsType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Validator\Constraints\Callback; -use Symfony\Component\Validator\Context\ExecutionContextInterface; class MultidomainType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { - $builder ->add('email', TextType::class, [ - 'label' => 'plugin.multidomain.email', + 'label' => 'plugin.multidomain.email', 'required' => true, - 'attr' => ['class' => 'form-control'] + 'attr' => ['class' => 'form-control'], ]) ->add('domain', TextType::class, [ - 'label' => 'plugin.multidomain.domain', + 'label' => 'plugin.multidomain.domain', 'required' => true, - 'attr' => ['class' => 'form-control'] - ]) - ; - - $builder->add( - 'buttons', - FormButtonsType::class - ); + 'attr' => ['class' => 'form-control'], + ]); + + $builder->add( + 'buttons', + FormButtonsType::class + ); if (!empty($options['action'])) { $builder->setAction($options['action']); - } + } } - + /** * {@inheritdoc} */ @@ -46,4 +40,4 @@ public function getBlockPrefix(): string { return 'multidomain_type'; } -} \ No newline at end of file +} diff --git a/MauticMultiDomainBundle.php b/MauticMultiDomainBundle.php index 5f53e5b..31b5681 100644 --- a/MauticMultiDomainBundle.php +++ b/MauticMultiDomainBundle.php @@ -2,8 +2,8 @@ namespace MauticPlugin\MauticMultiDomainBundle; -use Mautic\PluginBundle\Bundle\PluginBundleBase; use Mautic\CoreBundle\Factory\MauticFactory; +use Mautic\PluginBundle\Bundle\PluginBundleBase; use Mautic\PluginBundle\Entity\Plugin; /** diff --git a/Model/MultidomainModel.php b/Model/MultidomainModel.php index db5f031..e97e3af 100644 --- a/Model/MultidomainModel.php +++ b/Model/MultidomainModel.php @@ -1,29 +1,16 @@ formModel = $formModel; - $this->trackableModel = $trackableModel; - $this->leadFieldModel = $leadFieldModel; - $this->contactTracker = $contactTracker; - } + ) { + parent::__construct( + $em, + $security, + $dispatcher, + $router, + $translator, + $userHelper, + $logger, + $coreParametersHelper + ); + + $this->formModel = $formModel; + $this->trackableModel = $trackableModel; + $this->leadFieldModel = $leadFieldModel; + $this->contactTracker = $contactTracker; + } /** * MultidomainModel constructor. */ /*public function __construct( - \Mautic\FormBundle\Model\FormModel $formModel, - TrackableModel $trackableModel, - EventDispatcherInterface $dispatcher, - FieldModel $leadFieldModel, - ContactTracker $contactTracker, - EntityManager $entityManager + \Mautic\FormBundle\Model\FormModel $formModel, + TrackableModel $trackableModel, + EventDispatcherInterface $dispatcher, + FieldModel $leadFieldModel, + ContactTracker $contactTracker, + EntityManager $entityManager ) { - $this->formModel = $formModel; - $this->trackableModel = $trackableModel; - // $this->templating = $templating; - $this->dispatcher = $dispatcher; - $this->leadFieldModel = $leadFieldModel; - $this->contactTracker = $contactTracker; - + $this->formModel = $formModel; + $this->trackableModel = $trackableModel; + // $this->templating = $templating; + $this->dispatcher = $dispatcher; + $this->leadFieldModel = $leadFieldModel; + $this->contactTracker = $contactTracker; + }*/ /** @@ -199,8 +180,8 @@ public function getEntity($id = null): ?object /** * {@inheritdoc} * - * @param Multidomain $entity - * @param bool|false $unlock + * @param Multidomain $entity + * @param bool|false $unlock */ public function saveEntity($entity, $unlock = true): void { @@ -208,13 +189,9 @@ public function saveEntity($entity, $unlock = true): void $this->getRepository()->saveEntity($entity); } - /** * Get whether the color is light or dark. * - * @param $hex - * @param $level - * * @return bool */ public static function isLightColor($hex, $level = 200) @@ -278,5 +255,4 @@ public function getConfiArray() { return include dirname(__DIR__).'/Config/config.php'; } - } diff --git a/Permissions/MultidomainPermissions.php b/Permissions/MultidomainPermissions.php index da41a10..b7b5304 100644 --- a/Permissions/MultidomainPermissions.php +++ b/Permissions/MultidomainPermissions.php @@ -1,13 +1,5 @@ extend('MauticCoreBundle:Default:content.html.php'); - $view['slots']->set('mauticContent', 'multidomain'); - $view['slots']->set('headerTitle', $item->getEmail()); - - $view['slots']->set( - 'actions', - $view->render( - 'MauticCoreBundle:Helper:page_actions.html.php', - [ - 'item' => $item, - 'templateButtons' => [ - 'edit' => $view['security']->hasEntityAccess( - $permissions['multidomain:items:editown'], - $permissions['multidomain:items:editother'], - $item->getCreatedBy() - ), - 'clone' => $permissions['multidomain:items:create'], - 'delete' => $view['security']->hasEntityAccess( - $permissions['multidomain:items:deleteown'], - $permissions['multidomain:items:deleteother'], - $item->getCreatedBy() - ), - 'close' => $view['security']->isGranted('multidomain:items:view'), - ], - 'routeBase' => 'multidomain', - 'langVar' => 'multidomain', - ] - ) - ); - -?> - - -
- - -
-
-
- trans('plugin.multidomain.email'); ?>: -
-
- getEmail();?> -
-
- -
-
- trans('plugin.multidomain.domain'); ?>: -
-
-

getDomain();?>

-
-
-
-
\ No newline at end of file diff --git a/Resources/views/Multidomain/form.html.php b/Resources/views/Multidomain/form.html.php deleted file mode 100644 index fe56c1a..0000000 --- a/Resources/views/Multidomain/form.html.php +++ /dev/null @@ -1,49 +0,0 @@ -extend('MauticCoreBundle:Default:content.html.php'); - - -$view['slots']->set('mauticContent', 'multidomain'); - -$header = ($entity->getId()) - ? - $view['translator']->trans( - 'mautic.multidomain.edit', - ['%title%' => $view['translator']->trans($entity->getEmail())] - ) - : - $view['translator']->trans('mautic.multidomain.new'); -$view['slots']->set('headerTitle', $header); - -//$attr = $form->vars['attr']; -echo $view['form']->start($form); -?> - - -
- -
- -
-

- trans('mautic.multidomain.add.warning'); ?> -

-
-
-
- row($form['email']); ?> -
- -
- -
-
- row($form['domain']); ?> -
- -
-
-
- -end($form); ?> \ No newline at end of file diff --git a/Resources/views/Multidomain/index.html.php b/Resources/views/Multidomain/index.html.php deleted file mode 100644 index 1c0eb0e..0000000 --- a/Resources/views/Multidomain/index.html.php +++ /dev/null @@ -1,42 +0,0 @@ -extend('MauticCoreBundle:Default:content.html.php'); -$view['slots']->set('mauticContent', 'multidomain'); -$view['slots']->set('headerTitle', $view['translator']->trans('mautic.multidomain.title')); - -$view['slots']->set( - 'actions', - $view->render( - 'MauticCoreBundle:Helper:page_actions.html.php', - [ - 'templateButtons' => [ - 'new' => $permissions['multidomain:items:create'], - ], - 'routeBase' => 'multidomain', - ] - ) -); - -?> - -
- render( - 'MauticCoreBundle:Helper:list_toolbar.html.php', - [ - 'searchValue' => $searchValue, - 'searchHelp' => 'mautic.core.help.searchcommands', - 'action' => $currentRoute, - ] - ); ?> -
- output('_content'); ?> -
-
diff --git a/Resources/views/Multidomain/list.html.php b/Resources/views/Multidomain/list.html.php deleted file mode 100644 index 3656d41..0000000 --- a/Resources/views/Multidomain/list.html.php +++ /dev/null @@ -1,109 +0,0 @@ -extend('MauticMultiDomainBundle:Multidomain:index.html.php'); -} -?> - - -
- - - - render( - 'MauticCoreBundle:Helper:tableheader.html.php', - [ - 'checkall' => 'true', - 'target' => '#multidomainTable', - 'routeBase' => 'multidomain', - 'templateButtons' => [ - 'delete' => $permissions['multidomain:items:delete'], - ], - ] - ); - - echo $view->render( - 'MauticCoreBundle:Helper:tableheader.html.php', - [ - 'sessionVar' => 'multidomain', - 'orderBy' => 'f.email', - 'text' => 'plugin.multidomain.email', - 'class' => 'col-multidomain-name', - 'default' => true, - ] - ); - ?> - - - - - - - - - - -
- render( - 'MauticCoreBundle:Helper:list_actions.html.php', - [ - 'item' => $item, - 'templateButtons' => [ - 'edit' => $view['security']->hasEntityAccess( - $permissions['multidomain:items:editown'], - $permissions['multidomain:items:editother'], - $item->getCreatedBy() - ), - 'clone' => $permissions['multidomain:items:create'], - 'delete' => $view['security']->hasEntityAccess( - $permissions['multidomain:items:deleteown'], - $permissions['multidomain:items:deleteother'], - $item->getCreatedBy() - ), - ], - 'routeBase' => 'multidomain', - ] - ); - ?> - - - getDomain()): ?> -
- -
- -
-
- - - render('MauticCoreBundle:Helper:noresults.html.php', ['tip' => 'mautic.multidomain.noresults.tip']); ?> - From 7a36aaf1c466efc76ccf0d01a4b6631cbfb1e252 Mon Sep 17 00:00:00 2001 From: Matic Zagmajster Date: Fri, 2 May 2025 21:19:27 +0200 Subject: [PATCH 4/4] CS fix --- Config/config.php | 6 +++--- Config/services.php | 2 +- Event/MultidomainEvent.php | 1 - Permissions/MultidomainPermissions.php | 1 - 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Config/config.php b/Config/config.php index c622d26..3dc57b3 100644 --- a/Config/config.php +++ b/Config/config.php @@ -37,13 +37,13 @@ 'services' => [ 'forms' => [ 'mautic.form.type.multidomain' => [ - 'class' => \MauticPlugin\MauticMultiDomainBundle\Form\Type\MultidomainType::class, + 'class' => MauticPlugin\MauticMultiDomainBundle\Form\Type\MultidomainType::class, ], ], 'models' => [], 'events' => [ 'mautic.multidomain.subscriber.multidomain' => [ - 'class' => \MauticPlugin\MauticMultiDomainBundle\EventListener\MultidomianSubscriber::class, + 'class' => MauticPlugin\MauticMultiDomainBundle\EventListener\MultidomianSubscriber::class, 'arguments' => [ 'router', 'mautic.helper.ip_lookup', @@ -56,7 +56,7 @@ ], ], 'mautic.multidomain.subscriber.emailbuilder' => [ - 'class' => \MauticPlugin\MauticMultiDomainBundle\EventListener\BuilderSubscriber::class, + 'class' => MauticPlugin\MauticMultiDomainBundle\EventListener\BuilderSubscriber::class, 'arguments' => [ 'mautic.helper.core_parameters', 'mautic.email.model.email', diff --git a/Config/services.php b/Config/services.php index f7a39dc..b01b7b8 100644 --- a/Config/services.php +++ b/Config/services.php @@ -29,6 +29,6 @@ $services->alias( 'mautic.multidomain.model.multidomain', - \MauticPlugin\MauticMultiDomainBundle\Model\MultidomainModel::class + MauticPlugin\MauticMultiDomainBundle\Model\MultidomainModel::class ); }; diff --git a/Event/MultidomainEvent.php b/Event/MultidomainEvent.php index 1ec76ec..df1833b 100644 --- a/Event/MultidomainEvent.php +++ b/Event/MultidomainEvent.php @@ -1,6 +1,5 @@