Skip to content
Closed
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
2 changes: 1 addition & 1 deletion Command/CustomItemsScheduledExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace MauticPlugin\CustomObjectsBundle\Command;

use Mautic\CoreBundle\Helper\ExitCode;
use Mautic\CoreBundle\Templating\Helper\FormatterHelper;
use Mautic\CoreBundle\Twig\Helper\FormatterHelper;
use MauticPlugin\CustomObjectsBundle\CustomItemEvents;
use MauticPlugin\CustomObjectsBundle\Event\CustomItemExportSchedulerEvent;
use MauticPlugin\CustomObjectsBundle\Model\CustomItemExportSchedulerModel;
Expand Down
334 changes: 43 additions & 291 deletions Config/config.php

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions Config/services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

use Mautic\CoreBundle\DependencyInjection\MauticCoreExtension;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return function (ContainerConfigurator $configurator) {
$services = $configurator->services()
->defaults()
->autowire()
->autoconfigure()
->public();

$excludes = [
'Provider/SessionProvider.php',
'Report/ReportColumnsBuilder.php',
'Serializer/ApiNormalizer.php',
];

$services->load('MauticPlugin\\CustomObjectsBundle\\', '../')
->exclude('../{'.implode(',', array_merge(MauticCoreExtension::DEFAULT_EXCLUDES, $excludes)).'}');

$services->load('MauticPlugin\\CustomObjectsBundle\\Repository\\', '../Repository/*Repository.php');
};
7 changes: 4 additions & 3 deletions Controller/CustomField/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
use MauticPlugin\CustomObjectsBundle\Provider\CustomFieldRouteProvider;
use MauticPlugin\CustomObjectsBundle\Provider\CustomObjectRouteProvider;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class FormController extends CommonController
{
/**
* @var FormFactory
* @var FormFactoryInterface
*/
private $formFactory;

Expand Down Expand Up @@ -57,7 +58,7 @@ class FormController extends CommonController
private $objectRouteProvider;

public function __construct(
FormFactory $formFactory,
FormFactoryInterface $formFactory,
CustomFieldModel $customFieldModel,
CustomFieldFactory $customFieldFactory,
CustomFieldPermissionProvider $permissionProvider,
Expand Down Expand Up @@ -114,7 +115,7 @@ public function renderFormAction(Request $request): Response
'customField' => $customField,
'form' => $form->createView(),
],
'contentTemplate' => 'CustomObjectsBundle:CustomField:form.html.php',
'contentTemplate' => '@CustomObjects/CustomField/form.html.twig',
'passthroughVars' => [
'mauticContent' => 'customField',
'route' => $route,
Expand Down
11 changes: 6 additions & 5 deletions Controller/CustomField/SaveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
use MauticPlugin\CustomObjectsBundle\Provider\CustomFieldPermissionProvider;
use MauticPlugin\CustomObjectsBundle\Provider\CustomFieldRouteProvider;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* This controller is not used for saving to database, it is used only to generate forms and data validation.
Expand All @@ -32,7 +33,7 @@
class SaveController extends CommonController
{
/**
* @var FormFactory
* @var FormFactoryInterface
*/
private $formFactory;

Expand Down Expand Up @@ -62,7 +63,7 @@ class SaveController extends CommonController
private $customObjectModel;

public function __construct(
FormFactory $formFactory,
FormFactoryInterface $formFactory,
TranslatorInterface $translator,
CustomFieldModel $customFieldModel,
CustomFieldFactory $customFieldFactory,
Expand Down Expand Up @@ -134,7 +135,7 @@ public function saveAction(Request $request)
'customField' => $customField,
'form' => $form->createView(),
],
'contentTemplate' => 'CustomObjectsBundle:CustomField:form.html.php',
'contentTemplate' => '@CustomObjects/CustomField/form.html.twig',
'passthroughVars' => [
'mauticContent' => 'customField',
'route' => $route,
Expand Down Expand Up @@ -178,7 +179,7 @@ private function buildSuccessForm(CustomObject $customObject, CustomField $custo
);

$template = $this->render(
'CustomObjectsBundle:CustomObject:_form-fields.html.php',
'@CustomObjects/CustomObject/_form-fields.html.twig',
[
'form' => $form->createView(),
'panelId' => $panelId, // Panel id to me replaced if edit
Expand Down
2 changes: 2 additions & 0 deletions Controller/CustomItem/BatchDeleteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public function __construct(
$this->permissionProvider = $permissionProvider;
$this->routeProvider = $routeProvider;
$this->flashBag = $flashBag;

parent::setRequestStack($requestStack);
}

public function deleteAction(int $objectId): Response
Expand Down
11 changes: 9 additions & 2 deletions Controller/CustomItem/ContactListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
namespace MauticPlugin\CustomObjectsBundle\Controller\CustomItem;

use Mautic\CoreBundle\Controller\CommonController;
use Mautic\CoreBundle\Factory\PageHelperFactoryInterface;
use Mautic\LeadBundle\Controller\EntityContactsTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class ContactListController extends CommonController
Expand All @@ -15,9 +17,14 @@ class ContactListController extends CommonController
/**
* @codeCoverageIgnore as this just calls a Mautic core method
*/
public function listAction(int $objectId, int $page = 1): Response
{
public function listAction(
Request $request,
PageHelperFactoryInterface $pageHelperFactory,
int $objectId,
int $page = 1): Response {
return $this->generateContactsGrid(
$request,
$pageHelperFactory,
$objectId,
$page,
'lead:lists:viewother',
Expand Down
15 changes: 11 additions & 4 deletions Controller/CustomItem/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
use MauticPlugin\CustomObjectsBundle\Provider\CustomItemPermissionProvider;
use MauticPlugin\CustomObjectsBundle\Provider\CustomItemRouteProvider;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;

class FormController extends AbstractFormController
{
/**
* @var FormFactory
* @var FormFactoryInterface
*/
private $formFactory;

Expand Down Expand Up @@ -48,21 +50,26 @@ class FormController extends AbstractFormController
* @var LockFlashMessageHelper
*/
private $lockFlashMessageHelper;
private RequestStack $requestStack;

public function __construct(
FormFactory $formFactory,
FormFactoryInterface $formFactory,
CustomObjectModel $customObjectModel,
CustomItemModel $customItemModel,
CustomItemPermissionProvider $permissionProvider,
CustomItemRouteProvider $routeProvider,
LockFlashMessageHelper $lockFlashMessageHelper
LockFlashMessageHelper $lockFlashMessageHelper,
RequestStack $requestStack
) {
$this->formFactory = $formFactory;
$this->customObjectModel = $customObjectModel;
$this->customItemModel = $customItemModel;
$this->permissionProvider = $permissionProvider;
$this->routeProvider = $routeProvider;
$this->lockFlashMessageHelper = $lockFlashMessageHelper;

$this->requestStack = $requestStack;
parent::setRequestStack($requestStack);
}

public function newAction(int $objectId): Response
Expand Down Expand Up @@ -214,7 +221,7 @@ private function renderFormForItem(CustomItem $customItem, string $route, ?int $
'customObject' => $customItem->getCustomObject(),
'form' => $form->createView(),
],
'contentTemplate' => 'CustomObjectsBundle:CustomItem:form.html.php',
'contentTemplate' => '@CustomObjects/CustomItem/form.html.twig',
'passthroughVars' => [
'mauticContent' => 'customItem',
'route' => $route,
Expand Down
13 changes: 7 additions & 6 deletions Controller/CustomItem/LinkFormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
use MauticPlugin\CustomObjectsBundle\Provider\CustomItemPermissionProvider;
use MauticPlugin\CustomObjectsBundle\Provider\CustomItemRouteProvider;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use UnexpectedValueException;

class LinkFormController extends AbstractFormController
{
/**
* @var FormFactory
* @var FormFactoryInterface
*/
private $formFactory;

Expand All @@ -49,7 +50,7 @@ class LinkFormController extends AbstractFormController
private $routeProvider;

public function __construct(
FormFactory $formFactory,
FormFactoryInterface $formFactory,
CustomItemModel $customItemModel,
CustomItemPermissionProvider $permissionProvider,
CustomItemRouteProvider $customItemRouteProvider,
Expand Down Expand Up @@ -95,7 +96,7 @@ public function formAction(int $itemId, string $entityType, int $entityId): Resp
'customObject' => $relationshipObject,
'form' => $form->createView(),
],
'contentTemplate' => 'CustomObjectsBundle:CustomItem:form.html.php',
'contentTemplate' => '@CustomObjects/CustomItem/form.html.twig',
'passthroughVars' => [
'callback' => 'customItemLinkFormLoad',
'mauticContent' => 'customItem',
Expand All @@ -109,7 +110,7 @@ public function formAction(int $itemId, string $entityType, int $entityId): Resp

$responseData = [
'closeModal' => true,
'flashes' => $this->renderView('MauticCoreBundle:Notification:flash_messages.html.php'),
'flashes' => $this->renderView('MauticCoreBundle:Notification:flash_messages.html.twig'),
];

return new JsonResponse($responseData);
Expand Down Expand Up @@ -152,7 +153,7 @@ public function saveAction(int $itemId, string $entityType, int $entityId): Resp
$responseData = [
'closeModal' => true,
'callback' => $callback,
'flashes' => $this->renderView('MauticCoreBundle:Notification:flash_messages.html.php'),
'flashes' => $this->renderView('MauticCoreBundle:Notification:flash_messages.html.twig'),
];

return new JsonResponse($responseData);
Expand All @@ -170,7 +171,7 @@ public function saveAction(int $itemId, string $entityType, int $entityId): Resp
'form' => $form->createView(),
'tmpl' => $this->request->isXmlHttpRequest() ? $this->request->get('tmpl', 'index') : 'index',
],
'contentTemplate' => 'CustomObjectsBundle:CustomItem:form.html.php',
'contentTemplate' => '@CustomObjects/CustomItem/form.html.twig',
'passthroughVars' => [
'closeModal' => false,
'callback' => 'customItemLinkFormLoad',
Expand Down
4 changes: 3 additions & 1 deletion Controller/CustomItem/ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public function __construct(
$this->customObjectModel = $customObjectModel;
$this->permissionProvider = $permissionProvider;
$this->routeProvider = $routeProvider;

parent::setRequestStack($requestStack);
}

public function listAction(int $objectId, int $page = 1): Response
Expand Down Expand Up @@ -124,7 +126,7 @@ public function listAction(int $objectId, int $page = 1): Response
'sessionVar' => $namespace,
'namespace' => $namespace,
],
'contentTemplate' => 'CustomObjectsBundle:CustomItem:list.html.php',
'contentTemplate' => '@CustomObjects/CustomItem/list.html.twig',
'passthroughVars' => [
'mauticContent' => 'customItem',
'route' => $filterEntityType ? null : $route,
Expand Down
4 changes: 3 additions & 1 deletion Controller/CustomItem/SaveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public function __construct(
$this->permissionProvider = $permissionProvider;
$this->routeProvider = $routeProvider;
$this->lockFlashMessageHelper = $lockFlashMessageHelper;

parent::setRequestStack($requestStack);
}

public function saveAction(int $objectId, ?int $itemId = null): Response
Expand Down Expand Up @@ -203,7 +205,7 @@ public function saveAction(int $objectId, ?int $itemId = null): Response
'form' => $form->createView(),
'tmpl' => $request->isXmlHttpRequest() ? $request->get('tmpl', 'index') : 'index',
],
'contentTemplate' => 'CustomObjectsBundle:CustomItem:form.html.php',
'contentTemplate' => '@CustomObjects/CustomItem/form.html.twig',
'passthroughVars' => [
'mauticContent' => 'customItem',
'route' => $route,
Expand Down
4 changes: 3 additions & 1 deletion Controller/CustomItem/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public function __construct(
$this->auditLogModel = $auditLogModel;
$this->permissionProvider = $permissionProvider;
$this->routeProvider = $routeProvider;

parent::setRequestStack($requestStack);
}

public function viewAction(int $objectId, int $itemId): Response
Expand Down Expand Up @@ -114,7 +116,7 @@ public function viewAction(int $objectId, int $itemId): Response
]
)->getContent(),
],
'contentTemplate' => 'CustomObjectsBundle:CustomItem:detail.html.php',
'contentTemplate' => '@CustomObjects/CustomItem/detail.html.twig',
'passthroughVars' => [
'mauticContent' => 'customItem',
'activeLink' => "#mautic_custom_object_{$objectId}",
Expand Down
18 changes: 13 additions & 5 deletions Controller/CustomObject/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
use MauticPlugin\CustomObjectsBundle\Provider\CustomObjectPermissionProvider;
use MauticPlugin\CustomObjectsBundle\Provider\CustomObjectRouteProvider;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;

class FormController extends AbstractFormController
{
/**
* @var FormFactory
* @var FormFactoryInterface
*/
private $formFactory;

Expand Down Expand Up @@ -54,15 +57,17 @@ class FormController extends AbstractFormController
* @var LockFlashMessageHelper
*/
private $lockFlashMessageHelper;
private RequestStack $requestStack;

public function __construct(
FormFactory $formFactory,
FormFactoryInterface $formFactory,
CustomObjectModel $customObjectModel,
CustomFieldModel $customFieldModel,
CustomObjectPermissionProvider $permissionProvider,
CustomObjectRouteProvider $routeProvider,
CustomFieldTypeProvider $customFieldTypeProvider,
LockFlashMessageHelper $lockFlashMessageHelper
LockFlashMessageHelper $lockFlashMessageHelper,
RequestStack $requestStack
) {
$this->formFactory = $formFactory;
$this->customObjectModel = $customObjectModel;
Expand All @@ -71,9 +76,12 @@ public function __construct(
$this->routeProvider = $routeProvider;
$this->customFieldTypeProvider = $customFieldTypeProvider;
$this->lockFlashMessageHelper = $lockFlashMessageHelper;

$this->requestStack = $requestStack;
parent::setRequestStack($requestStack);
}

public function newAction(): Response
public function newAction(Request $request): Response
{
try {
$this->permissionProvider->canCreate();
Expand Down Expand Up @@ -144,7 +152,7 @@ private function renderForm(CustomObject $customObject, string $route): Response
'deletedFields' => [],
'form' => $form->createView(),
],
'contentTemplate' => 'CustomObjectsBundle:CustomObject:form.html.php',
'contentTemplate' => '@CustomObjects/CustomObject/form.html.twig',
'passthroughVars' => [
'mauticContent' => 'customObject',
'route' => $route,
Expand Down
Loading