public function ContactFormBlock::build in Form Block 8
Same name and namespace in other branches
- 2.0.x src/Plugin/Block/ContactFormBlock.php \Drupal\formblock\Plugin\Block\ContactFormBlock::build()
Implements \Drupal\block\BlockBase::build().
Overrides BlockPluginInterface::build
File
- src/
Plugin/ Block/ ContactFormBlock.php, line 180
Class
- ContactFormBlock
- Provides a block for contact form.
Namespace
Drupal\formblock\Plugin\BlockCode
public function build() {
$build = [];
// Check if flood control has been activated for sending emails.
if (!$this->currentUser
->hasPermission('administer contact forms') && ($message = $this
->floodControl())) {
$build['message'] = [
'#markup' => $message,
];
return $build;
}
$message = $this->entityTypeManager
->getStorage('contact_message')
->create([
'contact_form' => $this
->getContactForm()
->id(),
]);
$build['form'] = $this->entityFormBuilder
->getForm($message);
return $build;
}