InviteByEmailBlock.php in Invite 8
File
modules/invite_by_email/src/Plugin/Block/InviteByEmailBlock.php
View source
<?php
namespace Drupal\invite_by_email\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\invite_by_email\Form\InviteByEmailBlockForm;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Form\FormBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
class InviteByEmailBlock extends BlockBase implements ContainerFactoryPluginInterface {
protected $formBuilder;
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('form_builder'));
}
public function __construct(array $configuration, $plugin_id, $plugin_definition, FormBuilder $form_builder) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->formBuilder = $form_builder;
}
public function build() {
$block_id = $this
->getDerivativeId();
$build = [];
$form = $this->formBuilder
->getForm(new InviteByEmailBlockForm(), $block_id);
$build['form'] = $form;
return $build;
}
}