Use Doctrine in form editor
[MAILPOET-3644]
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
namespace MailPoet\Form\Util;
|
||||
|
||||
use MailPoet\Config\Env;
|
||||
use MailPoet\Entities\FormEntity;
|
||||
use MailPoet\Form\Widget;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class Export {
|
||||
public static function getAll($form = null) {
|
||||
public static function getAll(FormEntity $form = null) {
|
||||
return [
|
||||
'html' => static::get('html', $form),
|
||||
'php' => static::get('php', $form),
|
||||
@@ -16,12 +17,13 @@ class Export {
|
||||
];
|
||||
}
|
||||
|
||||
public static function get($type = 'html', $form = null) {
|
||||
public static function get($type = 'html', FormEntity $form = null) {
|
||||
if (!$form instanceof FormEntity) return '';
|
||||
switch ($type) {
|
||||
case 'iframe':
|
||||
// generate url to load iframe's content
|
||||
$iframeUrl = WPFunctions::get()->addQueryArg([
|
||||
'mailpoet_form_iframe' => $form['id'],
|
||||
'mailpoet_form_iframe' => $form->getId(),
|
||||
], WPFunctions::get()->siteUrl());
|
||||
|
||||
// generate iframe
|
||||
@@ -47,7 +49,7 @@ class Export {
|
||||
$output = [
|
||||
'$form_widget = new \MailPoet\Form\Widget();',
|
||||
'echo $form_widget->widget(array(\'form\' => ' .
|
||||
(int)$form['id'] .
|
||||
(int)$form->getId() .
|
||||
', \'form_type\' => \'php\'));',
|
||||
];
|
||||
return join("\n", $output);
|
||||
@@ -93,13 +95,13 @@ class Export {
|
||||
|
||||
$formWidget = new Widget();
|
||||
$output[] = $formWidget->widget([
|
||||
'form' => (int)$form['id'],
|
||||
'form' => (int)$form->getId(),
|
||||
'form_type' => 'php',
|
||||
]);
|
||||
return join("\n", $output);
|
||||
|
||||
case 'shortcode':
|
||||
return '[mailpoet_form id="' . (int)$form['id'] . '"]';
|
||||
return '[mailpoet_form id="' . (int)$form->getId() . '"]';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user