Commit b53c1b21 authored by karan  pagare's avatar karan pagare Committed by renatog
Browse files

Issue #3276084 by karanpagare, RenatoG, Ruturaj Chaubey: Fix all dependency injection in the Invite

parent 79ac65fd
Loading
Loading
Loading
Loading
+27 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Drupal\invite_link\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\invite_link\Form\InviteLinkBlockForm;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Provides an 'InviteLinkBlock' block.
@@ -19,10 +20,35 @@ class InviteLinkBlock extends BlockBase {
  /**
   * {@inheritdoc}
   */

  /**
   * FormBuilder.   *
   */
  protected $formBuilder;

  /**
   * Constructor.
   */
  public function __construct($formBuilder) {
    $this->formBuilder = $formBuilder;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
        $container->get('form_builder')
    );
  }

  /**
   * Build method.
   */
  public function build() {
    $block_id = $this->getDerivativeId();
    $build = [];
    $form = \Drupal::formBuilder()->getForm(new InviteLinkBlockForm(), $block_id);
    $form = $this->formBuilder->getForm(new InviteLinkBlockForm(), $block_id);
    $build['form'] = $form;

    return $build;
+10 −2
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ use Drupal\invite\Entity\InviteSender;
use Drupal\invite\InvitePluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Config\ConfigFactory;

/**
 * Form controller for Invite type edit forms.
@@ -48,6 +49,12 @@ class InviteTypeForm extends EntityForm {
   */
  protected $messenger;

  /**
   * {@inheritdoc}
   */

  protected $configFactory;

  /**
   * {@inheritdoc}
   */
@@ -63,11 +70,12 @@ class InviteTypeForm extends EntityForm {
  /**
   * {@inheritdoc}
   */
  public function __construct(InvitePluginManager $plugin_manager, BlockManager $block_plugin_manager, Connection $database, MessengerInterface $messenger) {
  public function __construct(InvitePluginManager $plugin_manager, BlockManager $block_plugin_manager, Connection $database, MessengerInterface $messenger, ConfigFactory $configFactory) {
    $this->pluginManager = $plugin_manager;
    $this->database = $database;
    $this->blockManager = $block_plugin_manager;
    $this->messenger = $messenger;
    $this->configFactory = $configFactory;
  }

  /**
@@ -75,7 +83,7 @@ class InviteTypeForm extends EntityForm {
   */
  public function getDefaultSendMethods($invite_type) {
    $defaults = [];
    foreach (explode('||', \Drupal::config('invite.invite_sender.' . $invite_type->getType())->get('sending_methods')) as $sending_method) {
    foreach (explode('||', $this->configFactory->get('invite.invite_sender.' . $invite_type->getType())->get('sending_methods')) as $sending_method) {
      if ($sending_method != '0') {
        $defaults[$sending_method] = $sending_method;
      }