Skip to content

Commit

Permalink
Merge pull request #8091 from Webmecanik/notification-bundle-deprecat…
Browse files Browse the repository at this point in the history
…ion-refactoring

Notification bundle deprecation refactoring
  • Loading branch information
escopecz committed Dec 9, 2019
2 parents bb91302 + be93305 commit 5644e18
Show file tree
Hide file tree
Showing 18 changed files with 199 additions and 165 deletions.
15 changes: 1 addition & 14 deletions app/bundles/NotificationBundle/Api/AbstractNotificationApi.php
Expand Up @@ -13,23 +13,12 @@

use Joomla\Http\Http;
use Joomla\Http\Response;
use Mautic\CoreBundle\Factory\MauticFactory;
use Mautic\NotificationBundle\Entity\Notification;
use Mautic\PageBundle\Model\TrackableModel;
use Mautic\PluginBundle\Helper\IntegrationHelper;

abstract class AbstractNotificationApi
{
/**
* @var string
*/
protected $apiUrl;

/**
* @var MauticFactory
*/
protected $factory;

/**
* @var Http
*/
Expand All @@ -48,14 +37,12 @@ abstract class AbstractNotificationApi
/**
* AbstractNotificationApi constructor.
*
* @param MauticFactory $factory
* @param Http $http
* @param TrackableModel $trackableModel
* @param IntegrationHelper $integrationHelper
*/
public function __construct(MauticFactory $factory, Http $http, TrackableModel $trackableModel, IntegrationHelper $integrationHelper)
public function __construct(Http $http, TrackableModel $trackableModel, IntegrationHelper $integrationHelper)
{
$this->factory = $factory;
$this->http = $http;
$this->trackableModel = $trackableModel;
$this->integrationHelper = $integrationHelper;
Expand Down
12 changes: 2 additions & 10 deletions app/bundles/NotificationBundle/Config/config.php
Expand Up @@ -80,61 +80,53 @@
'forms' => [
'mautic.form.type.notification' => [
'class' => 'Mautic\NotificationBundle\Form\Type\NotificationType',
'alias' => 'notification',
],
'mautic.form.type.mobile.notification' => [
'class' => \Mautic\NotificationBundle\Form\Type\MobileNotificationType::class,
'alias' => 'mobile_notification',
],
'mautic.form.type.mobile.notification_details' => [
'class' => \Mautic\NotificationBundle\Form\Type\MobileNotificationDetailsType::class,
'arguments' => [
'mautic.helper.integration',
],
'alias' => 'mobile_notification_details',
],
'mautic.form.type.notificationconfig' => [
'class' => 'Mautic\NotificationBundle\Form\Type\ConfigType',
'alias' => 'notificationconfig',
],
'mautic.form.type.notificationsend_list' => [
'class' => 'Mautic\NotificationBundle\Form\Type\NotificationSendType',
'arguments' => 'router',
'alias' => 'notificationsend_list',
],
'mautic.form.type.notification_list' => [
'class' => 'Mautic\NotificationBundle\Form\Type\NotificationListType',
'alias' => 'notification_list',
],
'mautic.form.type.mobilenotificationsend_list' => [
'class' => \Mautic\NotificationBundle\Form\Type\MobileNotificationSendType::class,
'arguments' => 'router',
'alias' => 'mobilenotificationsend_list',
],
'mautic.form.type.mobilenotification_list' => [
'class' => \Mautic\NotificationBundle\Form\Type\MobileNotificationListType::class,
'alias' => 'mobilenotification_list',
],
],
'helpers' => [
'mautic.helper.notification' => [
'class' => 'Mautic\NotificationBundle\Helper\NotificationHelper',
'alias' => 'notification_helper',
'arguments' => [
'mautic.factory',
'doctrine.orm.entity_manager',
'templating.helper.assets',
'mautic.helper.core_parameters',
'mautic.helper.integration',
'router',
'request_stack',
'mautic.lead.model.dnc',
],
],
],
'other' => [
'mautic.notification.api' => [
'class' => 'Mautic\NotificationBundle\Api\OneSignalApi',
'arguments' => [
'mautic.factory',
'mautic.http.connector',
'mautic.page.model.trackable',
'mautic.helper.integration',
Expand Down
Expand Up @@ -12,6 +12,7 @@
namespace Mautic\NotificationBundle\Controller\Api;

use Mautic\ApiBundle\Controller\CommonApiController;
use Mautic\LeadBundle\Tracker\ContactTracker;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;

Expand All @@ -20,11 +21,17 @@
*/
class NotificationApiController extends CommonApiController
{
/**
* @var ContactTracker
*/
protected $contactTracker;

/**
* {@inheritdoc}
*/
public function initialize(FilterControllerEvent $event)
{
$this->contactTracker = $this->container->get('mautic.tracker.contact');
$this->model = $this->getModel('notification');
$this->entityClass = 'Mautic\NotificationBundle\Entity\Notification';
$this->entityNameOne = 'notification';
Expand All @@ -45,7 +52,7 @@ public function subscribeAction()
/** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */
$leadModel = $this->getModel('lead');

if ($currentLead = $leadModel->getCurrentLead()) {
if ($currentLead = $this->contactTracker->getContact()) {
$currentLead->addPushIDEntry($osid);
$leadModel->saveEntity($currentLead);
}
Expand Down
Expand Up @@ -11,15 +11,15 @@

namespace Mautic\NotificationBundle\Controller;

use Mautic\CoreBundle\Controller\FormController;
use Mautic\CoreBundle\Controller\AbstractFormController;
use Mautic\CoreBundle\Form\Type\DateRangeType;
use Mautic\CoreBundle\Helper\InputHelper;
use Mautic\LeadBundle\Controller\EntityContactsTrait;
use Mautic\NotificationBundle\Entity\Notification;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;

class NotificationController extends FormController
class NotificationController extends AbstractFormController
{
use EntityContactsTrait;

Expand Down Expand Up @@ -587,7 +587,7 @@ public function cloneAction($objectId)
/**
* Deletes the entity.
*
* @param $objectId
* @param $objectId
*
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse
*/
Expand Down
Expand Up @@ -21,7 +21,7 @@ class PopupController extends CommonController
public function indexAction()
{
/** @var \Mautic\CoreBundle\Templating\Helper\AssetsHelper $assetsHelper */
$assetsHelper = $this->factory->getHelper('template.assets');
$assetsHelper = $this->container->get('templating.helper.assets');
$assetsHelper->addStylesheet('/app/bundles/NotificationBundle/Assets/css/popup/popup.css');

$response = $this->render(
Expand Down
Expand Up @@ -77,10 +77,12 @@ public function getHeading()
public function setHeading($heading)
{
$this->heading = $heading;

return $this;
}

/**
* @return array
* @return Lead
*/
public function getLead()
{
Expand Down
Expand Up @@ -15,6 +15,7 @@
use Mautic\ChannelBundle\Event\ChannelEvent;
use Mautic\ChannelBundle\Model\MessageModel;
use Mautic\CoreBundle\EventListener\CommonSubscriber;
use Mautic\NotificationBundle\Form\Type\NotificationListType;
use Mautic\PluginBundle\Helper\IntegrationHelper;
use Mautic\ReportBundle\Model\ReportModel;

Expand Down Expand Up @@ -66,7 +67,7 @@ public function onAddChannel(ChannelEvent $event)
'asset.download',
'form.submit',
],
'lookupFormType' => 'notification_list',
'lookupFormType' => NotificationListType::class,
'repository' => 'MauticNotificationBundle:Notification',
'lookupOptions' => [
'mobile' => false,
Expand All @@ -93,7 +94,7 @@ public function onAddChannel(ChannelEvent $event)
'asset.download',
'form.submit',
],
'lookupFormType' => 'notification_list',
'lookupFormType' => NotificationListType::class,
'repository' => 'MauticNotificationBundle:Notification',
'lookupOptions' => [
'mobile' => true,
Expand Down
Expand Up @@ -20,6 +20,7 @@
use Mautic\LeadBundle\Model\LeadModel;
use Mautic\NotificationBundle\Api\AbstractNotificationApi;
use Mautic\NotificationBundle\Event\NotificationSendEvent;
use Mautic\NotificationBundle\Form\Type\NotificationListType;
use Mautic\NotificationBundle\Model\NotificationModel;
use Mautic\NotificationBundle\NotificationEvents;
use Mautic\PluginBundle\Helper\IntegrationHelper;
Expand Down Expand Up @@ -89,7 +90,7 @@ public function onFormBuild(FormBuilderEvent $event)
'group' => 'mautic.notification.actions',
'description' => 'mautic.notification.actions.mobile_tooltip',
'label' => 'mautic.notification.actions.send_mobile_notification',
'formType' => 'notification_list',
'formType' => NotificationListType::class,
'formTheme' => 'MauticNotificationBundle:FormTheme\NotificationSendList',
'eventName' => NotificationEvents::NOTIFICATION_ON_FORM_ACTION_SEND,
];
Expand Down
13 changes: 7 additions & 6 deletions app/bundles/NotificationBundle/Form/Type/ConfigType.php
Expand Up @@ -13,6 +13,7 @@

use Mautic\CoreBundle\Form\Type\YesNoButtonGroupType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

/**
Expand Down Expand Up @@ -66,7 +67,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)

$builder->add(
'notification_app_id',
'text',
TextType::class,
[
'label' => 'mautic.notification.config.form.notification.app_id',
'data' => $options['data']['notification_app_id'],
Expand All @@ -80,7 +81,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)

$builder->add(
'notification_safari_web_id',
'text',
TextType::class,
[
'label' => 'mautic.notification.config.form.notification.safari_web_id',
'data' => $options['data']['notification_safari_web_id'],
Expand All @@ -94,7 +95,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)

$builder->add(
'notification_rest_api_key',
'text',
TextType::class,
[
'label' => 'mautic.notification.config.form.notification.rest_api_key',
'data' => $options['data']['notification_rest_api_key'],
Expand All @@ -107,7 +108,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
);
$builder->add(
'gcm_sender_id',
'text',
TextType::class,
[
'label' => 'mautic.notification.config.form.notification.gcm_sender_id',
'data' => $options['data']['gcm_sender_id'],
Expand All @@ -121,7 +122,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)

$builder->add(
'notification_subdomain_name',
'text',
TextType::class,
[
'label' => 'mautic.notification.config.form.notification.subdomain_name',
'data' => $options['data']['notification_subdomain_name'],
Expand Down Expand Up @@ -150,7 +151,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
/**
* {@inheritdoc}
*/
public function getName()
public function getBlockPrefix()
{
return 'notificationconfig';
}
Expand Down
Expand Up @@ -274,7 +274,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
/**
* @return string
*/
public function getName()
public function getBlockPrefix()
{
return 'mobile_notification_details';
}
Expand Down
Expand Up @@ -61,7 +61,7 @@ public function configureOptions(OptionsResolver $resolver)
/**
* @return string
*/
public function getName()
public function getBlockPrefix()
{
return 'mobilenotification_list';
}
Expand Down

0 comments on commit 5644e18

Please sign in to comment.