PardotFormMappingController.php in Pardot Integration 2.x
File
src/Controller/PardotFormMappingController.php
View source
<?php
namespace Drupal\pardot\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\pardot\Form\PardotFormMappingForm;
class PardotFormMappingController extends ControllerBase {
protected $entityTypeManager;
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->entityTypeManager = $container
->get('entity_type.manager');
return $instance;
}
public function renderContactFormMapping($contact_form) {
$entity = $this->entityTypeManager
->getStorage('contact_form')
->load($contact_form);
if ($entity) {
return \Drupal::formBuilder()
->getForm(PardotFormMappingForm::class, $entity, 'contact_form_mapping');
}
else {
return [
'#markup' => 'Could not find a matching entity.',
];
}
}
public function renderWebformFormMapping($webform) {
$entity = $this->entityTypeManager
->getStorage('webform')
->load($webform);
if ($entity) {
return \Drupal::formBuilder()
->getForm(PardotFormMappingForm::class, $entity, 'webform_mapping');
}
else {
return [
'#markup' => 'Could not find a matching entity.',
];
}
}
}