Use explicit code instead of PHP magic

[MAILPOET-1798]
This commit is contained in:
Pavel Dohnal
2020-02-06 13:38:53 +01:00
committed by Jack Kitterhing
parent 8da7330a8d
commit 831a865c9e
2 changed files with 6 additions and 3 deletions

View File

@ -2,6 +2,7 @@
namespace MailPoet\Config;
use MailPoet\Entities\FormEntity;
use MailPoet\Form\FormsRepository;
use MailPoet\Form\Widget;
use MailPoet\WP\Functions as WPFunctions;
@ -72,7 +73,9 @@ class PostEditorBlock {
$forms = $this->formsRepository->findAllNotDeleted();
?>
<script type="text/javascript">
window.mailpoet_forms = <?php echo json_encode($forms) ?>;
window.mailpoet_forms = <?php echo json_encode(array_map(function(FormEntity $form) {
return $form->toArray();
}, $forms)) ?>;
window.locale = {
selectForm: '<?php echo __('Select a MailPoet form', 'mailpoet') ?>',
createForm: '<?php echo __('Create a new form', 'mailpoet') ?>',

View File

@ -12,7 +12,7 @@ use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
* @ORM\Entity()
* @ORM\Table(name="forms")
*/
class FormEntity implements \JsonSerializable {
class FormEntity {
use AutoincrementedIdTrait;
use CreatedAtTrait;
use UpdatedAtTrait;
@ -102,7 +102,7 @@ class FormEntity implements \JsonSerializable {
$this->styles = $styles;
}
public function jsonSerialize() {
public function toArray() {
return [
'id' => $this->getId(),
'name' => $this->getName(),