/**
  * {@inheritdoc}
  */
 public function build()
 {
     $form = $this->entity_manager->getStorage('contact_message')->create(array('contact_form' => $this->configuration['contact_form']));
     if (!$form) {
         return '';
     }
     $form = $this->entity_form_builder->getForm($form);
     return $form;
 }
Esempio n. 2
-4
 /**
  * {@inheritdoc}
  */
 public function build()
 {
     $form = array();
     /** @var \Drupal\contact\Entity\ContactForm $contact_form */
     $contact_form = $this->getContactForm();
     if ($contact_form) {
         $contact_message = $this->createContactMessage();
         // The personal contact form has a fixed recipient: the user who's
         // contact page we visit. We use the 'user' property from the URL
         // to determine this user. For example: user/{user}.
         if ($contact_message->isPersonal()) {
             $user = \Drupal::routeMatch()->getParameter('user');
             $contact_message->set('recipient', $user);
         }
         $form = $this->entityFormBuilder->getForm($contact_message);
         $form['#cache']['contexts'][] = 'user.permissions';
         $this->renderer->addCacheableDependency($form, $contact_form);
     }
     return $form;
 }