Commit 91d8aacd authored by Andrew Hughes-Onslow's avatar Andrew Hughes-Onslow Committed by renatog
Browse files

Issue #2976921 by kalpaitch, keshav.k, 7thkey: Plugin not plugin

parent 49677d79
Loading
Loading
Loading
Loading
+22 −6
Changes for modules/invite_by_email/src/Plugin/Invite/InviteByEmail.php: 22 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -2,7 +2,9 @@

namespace Drupal\invite_by_email\Plugin\Invite;

use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\invite\InvitePluginInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -16,7 +18,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
 *   label = @Translation("Invite By Email")
 * )
 */
class InviteByEmail implements InvitePluginInterface {
class InviteByEmail extends PluginBase implements InvitePluginInterface, ContainerFactoryPluginInterface {

  use StringTranslationTrait;

@@ -28,20 +30,33 @@ class InviteByEmail implements InvitePluginInterface {
  protected $messenger;

  /**
   * Constructs InviteByEmail .
   * Getter for the messenger service.
   *
   * @return \Drupal\Core\Messenger\MessengerInterface
   */
  public function getMessenger() {
    return $this->messenger;
  }

  /**
   * Constructs invite_by_email plugin.
   *
   * @param \Drupal\Core\Messenger\MessengerInterface $messenger
   *   The messenger service.
   */
  public function __construct(MessengerInterface $messenger) {
  public function __construct(array $configuration, $plugin_id, $plugin_definition, MessengerInterface $messenger) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->messenger = $messenger;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->get('messenger')
    );
  }
@@ -85,7 +100,7 @@ class InviteByEmail implements InvitePluginInterface {

    if ($result) {

      $this->messenger->addStatus($this->t('Invitation has been sent.'));
      $this->getMessenger()->addStatus($this->t('Invitation has been sent.'));

      $mail_user = $message['to'];

@@ -95,7 +110,7 @@ class InviteByEmail implements InvitePluginInterface {
    }
    else {

      $this->messenger->addStatus($this->t('Failed to send a message.'), 'error');
      $this->getMessenger()->addStatus($this->t('Failed to send a message.'), 'error');

      \Drupal::logger('invite')->error('Failed to send a message.');
    }
@@ -103,3 +118,4 @@ class InviteByEmail implements InvitePluginInterface {
  }

}
+2 −1
Changes for modules/invite_link/src/Plugin/Invite/InviteLink.php: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\invite_link\Plugin\Invite;

use Drupal\invite\InvitePluginInterface;
use Drupal\Component\Plugin\PluginBase;

/**
 * Example plugin. Simplest use case.
@@ -12,7 +13,7 @@ use Drupal\invite\InvitePluginInterface;
 *   label = @Translation("Invite Link")
 * )
 */
class InviteLink implements InvitePluginInterface {
class InviteLink extends PluginBase implements InvitePluginInterface {

  /**
   * {@inheritdoc}