Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

feat: Extend messaging to applications #81

Merged
19 changes: 17 additions & 2 deletions module/Olcs/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Common\Data\Object\Search\Vehicle;
use Common\Service\Data as CommonDataService;
use Laminas\Cache\Service\StorageCacheAbstractServiceFactory;
use Laminas\Http\Request;
use Laminas\Router\RouteStackInterface;
use Olcs\Auth;
use Olcs\Controller\Application as ApplicationControllers;
use Olcs\Controller\Application\ApplicationController;
Expand Down Expand Up @@ -69,6 +71,8 @@
use Olcs\Controller\Lva\Variation as LvaVariationControllers;
use Olcs\Controller\Messages\ApplicationConversationListController;
use Olcs\Controller\Messages\ApplicationCreateConversationController;
use Olcs\Controller\Messages\ApplicationConversationMessagesController;
use Olcs\Controller\Messages\ApplicationEnableDisableMessagingController;
use Olcs\Controller\Messages\LicenceConversationListController;
use Olcs\Controller\Messages\LicenceConversationMessagesController;
use Olcs\Controller\Messages\LicenceCreateConversationController;
Expand Down Expand Up @@ -301,12 +305,15 @@
LvaVariationControllers\VehiclesPsvController::class => LvaVariationControllerFactories\VehiclesPsvControllerFactory::class,
LvaVariationControllers\WithdrawController::class => LvaVariationControllerFactories\WithdrawControllerFactory::class,
Olcs\Controller\IndexController::class => Olcs\Controller\Factory\IndexControllerFactory::class,
Olcs\Controller\Messages\ApplicationConversationMessagesController::class => Olcs\Controller\Factory\Messages\ApplicationConversationMessagesControllerFactory::class,
Olcs\Controller\Messages\LicenceConversationMessagesController::class => Olcs\Controller\Factory\Messages\LicenceConversationMessagesControllerFactory::class,
Olcs\Controller\Messages\ApplicationConversationListController::class => Olcs\Controller\Factory\Messages\ApplicationConversationListControllerFactory::class,
Olcs\Controller\Messages\LicenceConversationListController::class => Olcs\Controller\Factory\Messages\LicenceConversationListControllerFactory::class,
Olcs\Controller\Messages\ApplicationEnableDisableMessagingController::class => Olcs\Controller\Factory\Messages\ApplicationEnableDisableMessagingControllerFactory::class,
Olcs\Controller\Messages\LicenceEnableDisableMessagingController::class => Olcs\Controller\Factory\Messages\LicenceEnableDisableMessagingControllerFactory::class,
Olcs\Controller\Messages\ApplicationCreateConversationController::class => Olcs\Controller\Factory\Messages\LicenceCreateConversationControllerFactory::class,
Olcs\Controller\Messages\ApplicationCreateConversationController::class => Olcs\Controller\Factory\Messages\ApplicationCreateConversationControllerFactory::class,
Olcs\Controller\Messages\LicenceCreateConversationController::class => Olcs\Controller\Factory\Messages\LicenceCreateConversationControllerFactory::class,
Olcs\Controller\Messages\ApplicationCloseConversationController::class => Olcs\Controller\Factory\Messages\ApplicationCloseConversationControllerFactory::class,
Olcs\Controller\Messages\LicenceCloseConversationController::class => Olcs\Controller\Factory\Messages\LicenceCloseConversationControllerFactory::class,
OperatorControllers\OperatorFeesController::class => OperatorControllerFactories\OperatorFeesControllerFactory::class,
OperatorControllers\OperatorProcessingTasksController::class => OperatorControllerFactories\OperatorProcessingTasksControllerFactory::class,
Expand Down Expand Up @@ -677,7 +684,9 @@
'Helper\ApplicationOverview' => HelperService\ApplicationOverviewHelperService::class,
'Helper\LicenceOverview' => HelperService\LicenceOverviewHelperService::class,
'Processing\CreateVariation' => ProcessingService\CreateVariationProcessingServiceFactory::class,
'LicenceListener' => LicenceListener::class
'LicenceListener' => LicenceListener::class,
RouteStackInterface::class => 'Router',
Request::class => 'Request',
],
'invokables' => [
'ApplicationUtility' => 'Olcs\Service\Utility\ApplicationUtility',
Expand Down Expand Up @@ -833,6 +842,9 @@
RouteParam\LicenceFurniture::class,
RouteParam\Licence::class,
],
ApplicationEnableDisableMessagingController::class => [
RouteParam\Conversation::class,
],
LicenceEnableDisableMessagingController::class => [
RouteParam\Conversation::class,
],
Expand All @@ -845,6 +857,9 @@
LicenceConversationMessagesController::class => [
RouteParam\Conversation::class,
],
ApplicationConversationMessagesController::class => [
RouteParam\Conversation::class,
],
LicenceCreateConversationController::class => [
RouteParam\Conversation::class,
],
Expand Down
9 changes: 8 additions & 1 deletion module/Olcs/config/navigation.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1410,11 +1410,18 @@
'use_route_match' => true,
],
[
'id' => 'conversation_list_disable_messaging',
'id' => 'application_conversation_list_disable_messaging',
'label' => 'Disable Messaging',
'route' => 'lva-application/conversation/disable',
'class' => 'govuk-link--no-visited-state',
'use_route_match' => true,
],
[
'id' => 'application_conversation_list_enable_messaging',
'label' => 'Enable Messaging',
'route' => 'lva-application/conversation/enable',
'class' => 'govuk-link--no-visited-state',
'use_route_match' => true,
]
],
],
Expand Down
63 changes: 59 additions & 4 deletions module/Olcs/config/routes.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2644,7 +2644,7 @@
'print-receipt' => $feePrintReceiptRoute,
)
),
'conversation' => [
'conversation' => [
'type' => 'segment',
'options' => [
'route' => 'conversation[/]',
Expand All @@ -2662,7 +2662,7 @@
'route' => ':conversation[/]',
'verb' => 'GET',
'defaults' => [
'controller' => Olcs\Controller\Messages\LicenceConversationMessagesController::class,
'controller' => Olcs\Controller\Messages\ApplicationConversationMessagesController::class,
'action' => 'index'
],
],
Expand All @@ -2680,17 +2680,72 @@
],
'may_terminate' => true,
],
'close' => [
'type' => 'segment',
'options' => [
'route' => ':conversation/close[/]',
'defaults' => [
'controller' => Olcs\Controller\Messages\ApplicationCloseConversationController::class,
'action' => 'confirm'
],
],
'may_terminate' => true,
],
'disable' => [
'type' => 'segment',
'options' => [
'route' => 'disable[/]',
'verb' => 'GET',
'defaults' => [
'controller' => Olcs\Controller\Messages\LicenceEnableDisableMessagingController::class,
'action' => 'index'
'controller' => Olcs\Controller\Messages\ApplicationEnableDisableMessagingController::class,
'action' => 'index',
'type' => 'disable',
]
],
'may_terminate' => true,
'child_routes' => [
'popup' => [
'type' => 'segment',
'options' => [
'route' => 'popup[/]',
'verb' => 'POST',
'defaults' => [
'controller' => Olcs\Controller\Messages\ApplicationEnableDisableMessagingController::class,
'action' => 'popup',
'type' => 'disable',
],
],
'may_terminate' => true,
],
],
],
'enable' => [
'type' => 'segment',
'options' => [
'route' => 'enable[/]',
'verb' => 'GET',
'defaults' => [
'controller' => Olcs\Controller\Messages\ApplicationEnableDisableMessagingController::class,
'action' => 'index',
'type' => 'enable',
]
],
'may_terminate' => true,
'child_routes' => [
'popup' => [
'type' => 'segment',
'options' => [
'route' => 'popup[/]',
'verb' => 'POST',
'defaults' => [
'controller' => Olcs\Controller\Messages\ApplicationEnableDisableMessagingController::class,
'action' => 'popup',
'type' => 'enable',
],
],
'may_terminate' => true,
],
],
],
],
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace Olcs\Controller\Factory\Messages;

use Common\Service\Helper\FlashMessengerHelperService;
use Common\Service\Helper\FormHelperService;
use Common\Service\Script\ScriptFactory;
use Common\Service\Table\TableFactory;
use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Laminas\View\HelperPluginManager;
use Olcs\Controller\Messages\ApplicationCloseConversationController;

class ApplicationCloseConversationControllerFactory implements FactoryInterface
{
public function __invoke(
ContainerInterface $container,
$requestedName,
?array $options = null
): ApplicationCloseConversationController
{
$scriptFactory = $container->get(ScriptFactory::class);
$formHelper = $container->get(FormHelperService::class);
$tableFactory = $container->get(TableFactory::class);
$viewHelperManager = $container->get(HelperPluginManager::class);
$flashMessengerHelperService = $container->get(FlashMessengerHelperService::class);

return new ApplicationCloseConversationController(
$scriptFactory,
$formHelper,
$tableFactory,
$viewHelperManager,
$flashMessengerHelperService,
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace Olcs\Controller\Factory\Messages;

use Common\Service\Helper\FlashMessengerHelperService;
use Common\Service\Helper\FormHelperService;
use Common\Service\Helper\TranslationHelperService;
use Common\Service\Script\ScriptFactory;
use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Olcs\Controller\Messages\ApplicationConversationMessagesController;

class ApplicationConversationMessagesControllerFactory implements FactoryInterface
{
public function __invoke(ContainerInterface $container, $requestedName, array $options = null): ApplicationConversationMessagesController
{
$formHelper = $container->get(FormHelperService::class);
$translationHelper = $container->get(TranslationHelperService::class);
$flashMessenger = $container->get(FlashMessengerHelperService::class);
$scriptsFactory = $container->get(ScriptFactory::class);

$navigation = $container->get('navigation');

return new ApplicationConversationMessagesController(
$translationHelper,
$formHelper,
$flashMessenger,
$navigation,
$scriptsFactory
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

namespace Olcs\Controller\Factory\Messages;

use Common\Service\Data\PluginManager;
use Common\Service\Helper\ComplaintsHelperService;
use Common\Service\Helper\FlashMessengerHelperService;
use Common\Service\Helper\FormHelperService;
use Common\Service\Helper\OppositionHelperService;
use Common\Service\Helper\UrlHelperService;
use Common\Service\Script\ScriptFactory;
use Common\Service\Table\TableFactory;
use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Laminas\View\HelperPluginManager;
use Olcs\Controller\Messages\ApplicationEnableDisableMessagingController;

class ApplicationEnableDisableMessagingControllerFactory implements FactoryInterface
{
public function __invoke(ContainerInterface $container, $requestedName, array $options = null): ApplicationEnableDisableMessagingController
{
$scriptFactory = $container->get(ScriptFactory::class);
$formHelper = $container->get(FormHelperService::class);
$tableFactory = $container->get(TableFactory::class);
$viewHelperManager = $container->get(HelperPluginManager::class);
$dataServiceManager = $container->get(PluginManager::class);
$oppositionHelper = $container->get(OppositionHelperService::class);
$complaintsHelper = $container->get(ComplaintsHelperService::class);
$flashMessengerHelper = $container->get(FlashMessengerHelperService::class);
$urlHelper = $container->get(UrlHelperService::class);

return new ApplicationEnableDisableMessagingController(
$scriptFactory,
$formHelper,
$tableFactory,
$viewHelperManager,
$dataServiceManager,
$oppositionHelper,
$complaintsHelper,
$flashMessengerHelper,
$urlHelper,
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

declare(strict_types=1);

namespace Olcs\Controller\Messages;

use Common\Controller\Interfaces\ToggleAwareInterface;
use Common\FeatureToggle;
use Common\Service\Helper\FlashMessengerHelperService;
use Common\Service\Helper\FormHelperService;
use Common\Service\Script\ScriptFactory;
use Common\Service\Table\TableFactory;
use Dvsa\Olcs\Transfer\Command\Messaging\Conversation\Close;
use Laminas\Http\Response;
use Laminas\View\HelperPluginManager;
use Laminas\View\Model\ViewModel;
use Olcs\Controller\AbstractController;
use Olcs\Data\Mapper\Task;
use Olcs\Form\Model\Form\CloseConversation;

abstract class AbstractCloseConversationController extends AbstractController implements ToggleAwareInterface
{
protected array $toggleConfig = [
'default' => [FeatureToggle::MESSAGING],
];
private FlashMessengerHelperService $flashMessengerHelperService;

public function __construct(
ScriptFactory $scriptFactory,
FormHelperService $formHelper,
TableFactory $tableFactory,
HelperPluginManager $viewHelperManager,
FlashMessengerHelperService $flashMessengerHelperService
) {
parent::__construct($scriptFactory, $formHelper, $tableFactory, $viewHelperManager);

$this->flashMessengerHelperService = $flashMessengerHelperService;
}

abstract protected function getRedirect(): Response;

/**
* @return ViewModel|Response
*/
public function confirmAction()
{
$form = $this->getForm(CloseConversation::class);
$form->get('id')->setValue($this->params()->fromRoute('conversation'));

if ($this->getRequest()->isPost()) {
$closeCommand = Close::create(['id' => $this->params()->fromRoute('conversation')]);
$response = $this->handleCommand($closeCommand);

if ($response->isOk()) {
$this->flashMessengerHelperService->addSuccessMessage('conversation-closed-success');

return $this->getRedirect();
} else {
if ($response->isClientError()) {
Task::mapFormErrors($response->getResult()['messages'], $form, $this->flashMessengerHelperService);
} else {
$this->flashMessengerHelperService->addUnknownError();
}
}
}

$view = new ViewModel(['form' => $form]);
$view->setTemplate('pages/form');

return $this->renderView($view, 'End Conversation');
}
}
Loading
Loading