Commit fdfbd7cf authored by beagaliana's avatar beagaliana Committed by Pedro Cambra
Browse files

Issue #3263367: Add KeyRepositoryInterface for object declaration in key module integration

parent 83baa5cd
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ namespace Drupal\whatsapp\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\key\KeyRepository;
use Drupal\key\KeyRepositoryInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

@@ -27,11 +27,11 @@ class WhatsappBlock extends BlockBase implements ContainerFactoryPluginInterface
  protected $configFactory;

  /**
   * The key.
   * The key repository.
   *
   * @var \Drupal\key\KeyRepository
   * @var \Drupal\key\KeyRepositoryInterface
   */
  protected $configKey;
  protected $keyRepository;

  /**
   * Constructs a new WhatsappBlock object.
@@ -44,13 +44,13 @@ class WhatsappBlock extends BlockBase implements ContainerFactoryPluginInterface
   *   The plugin implementation definition.
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The factory for configuration objects.
   * @param \Drupal\key\KeyRepository $config_key
   *   The key.
   * @param \Drupal\key\KeyRepositoryInterface $key_repository
   *   The key repository service.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, KeyRepository $config_key) {
  public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, KeyRepositoryInterface $key_repository) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->configFactory = $config_factory;
    $this->configKey = $config_key;
    $this->keyRepository = $key_repository;
  }

  /**
@@ -71,7 +71,7 @@ class WhatsappBlock extends BlockBase implements ContainerFactoryPluginInterface
   */
  public function build() {
    $widget_key = $this->configFactory->get('whatsapp.settings')->get('widget_key');
    $key = $this->configKey->getKey($widget_key)->getKeyValue();
    $key = $this->keyRepository->getKey($widget_key)->getKeyValue();

    return [
      '#type' => 'inline_template',