forked from mautic/mautic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [DPMMA-796] Add export lead contact info (mautic#13981)
* fix: [DPMMA-796] Add export lead contact info * fix: [DPMMA-796] Correct tests * feat: [DPMMA-796] Correct AuditLog exports * feat: [DPMMA-796] Add functional test * fix: [DPMMA-796] Add filter Contact Exports
- Loading branch information
1 parent
ce948d1
commit 81bbae3
Showing
7 changed files
with
154 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mautic\LeadBundle\Event; | ||
|
||
use Symfony\Contracts\EventDispatcher\Event; | ||
|
||
class ContactExportEvent extends Event | ||
{ | ||
/** | ||
* @param array<string|int, string|array<string, mixed>> $args | ||
*/ | ||
public function __construct( | ||
private array $args, | ||
private string $object | ||
) { | ||
} | ||
|
||
/** | ||
* @return array<string, string|array<string, mixed>> | ||
*/ | ||
public function getArgs(): array | ||
{ | ||
return $this->args; | ||
} | ||
|
||
public function getObject(): string | ||
{ | ||
return $this->object; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
app/bundles/LeadBundle/EventListener/ContactExportAuditLogSubscriber.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mautic\LeadBundle\EventListener; | ||
|
||
use Mautic\CoreBundle\Helper\IpLookupHelper; | ||
use Mautic\CoreBundle\Model\AuditLogModel; | ||
use Mautic\LeadBundle\Event\ContactExportEvent; | ||
use Mautic\LeadBundle\LeadEvents; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
class ContactExportAuditLogSubscriber implements EventSubscriberInterface | ||
{ | ||
public function __construct( | ||
private AuditLogModel $auditLogModel, | ||
private IpLookupHelper $ipLookupHelper | ||
) { | ||
} | ||
|
||
public static function getSubscribedEvents(): array | ||
{ | ||
return [ | ||
LeadEvents::POST_CONTACT_EXPORT => 'onContactExport', | ||
]; | ||
} | ||
|
||
public function onContactExport(ContactExportEvent $event): void | ||
{ | ||
$this->auditLogModel->writeToLog( | ||
[ | ||
'bundle' => 'lead', | ||
'object' => $event->getObject(), | ||
'objectId' => 0, | ||
'action' => 'create', | ||
'details' => $event->getArgs(), | ||
'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest(), | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters