Skip to content

Commit

Permalink
allow to get and put publicPreview flag for email through API
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kozak <[email protected]>
  • Loading branch information
galvani committed Mar 22, 2024
1 parent 471a179 commit fa2b928
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/bundles/EmailBundle/Controller/Api/EmailApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Mautic\LeadBundle\Entity\Lead;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -214,4 +215,13 @@ public function replyAction(Reply $replyService, RandomHelperInterface $randomHe
$this->view(['success' => true], Response::HTTP_CREATED)
);
}

protected function prepareParametersFromRequest(FormInterface $form, array &$params, object $entity = null, array $masks = [], array $fields = []): void
{
if (isset($params['publicPreview']) && $entity instanceof Email) {
$entity->setPublicPreview(InputHelper::boolean($params['publicPreview']) ?? false);
unset($params['publicPreview']);
}
parent::prepareParametersFromRequest($form, $params, $entity, $masks, $fields);
}
}
1 change: 1 addition & 0 deletions app/bundles/EmailBundle/Entity/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ public static function loadApiMetadata(ApiMetadataDriver $metadata): void
'emailType',
'publishUp',
'publishDown',
'publicPreview',
'readCount',
'sentCount',
'revision',
Expand Down

0 comments on commit fa2b928

Please sign in to comment.