Skip to content
Snippets Groups Projects
Commit 980a6164 authored by Indra Patil's avatar Indra Patil Committed by Daniel Speicher
Browse files

Issue #3372810 by Indrapatil, nitin_lama: Fix the issues reported by phpcs

parent 1f85a49d
No related branches found
No related tags found
1 merge request!7Fixed the coding standards.
......@@ -16,10 +16,16 @@ use Drupal\eca\Token\DataProviderInterface;
*/
class DirectPush extends BaseEvent implements DataProviderInterface {
/**
* {@inheritdoc}
*/
public function getData(string $key): ?DataTransferObject {
return NULL;
}
/**
* {@inheritdoc}
*/
public function hasData(string $key): bool {
return ($key === '');
}
......
......@@ -11,7 +11,7 @@ use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\node\Entity\Node;
use Drupal\push_framework\ChannelPluginManager;
use Drupal\user\Entity\User;
use Drupal\Core\Plugin\ContextAwarePluginManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -39,17 +39,56 @@ class Notify extends ConfigurableActionBase implements ContainerFactoryPluginInt
protected EntityTypeBundleInfoInterface $entityTypeBundleInfo;
/**
* The current user account.
*
* @var \Drupal\Core\Session\AccountProxyInterface
* Represents the currently authenticated user session within Drupal.
* Provides methods to retrieve information about the user,
* such as their ID, username, roles, and permissions.
*/
protected AccountProxyInterface $currentUser;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ChannelPluginManager $channelPluginManager, EntityTypeBundleInfoInterface $entityTypeBundleInfo, AccountProxyInterface $currentUser) {
/**
* Constructs a new instance of the class.
*
* @param array $configuration
* An array of configuration values for the plugin.
* @param string $plugin_id
* The plugin ID.
* @param mixed $plugin_definition
* The plugin definition.
* @param \Drupal\Core\Plugin\ContextAwarePluginManagerInterface $channelPluginManager
* The channel plugin manager.
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entityTypeBundleInfo
* The entity type bundle info service.
* @param \Drupal\Core\Session\AccountProxyInterface $currentUser
* The current user account.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, ContextAwarePluginManagerInterface $channelPluginManager, EntityTypeBundleInfoInterface $entityTypeBundleInfo, AccountProxyInterface $currentUser, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->channelPluginManager = $channelPluginManager;
$this->entityTypeBundleInfo = $entityTypeBundleInfo;
$this->currentUser = $currentUser;
$this->userStorage = $entity_type_manager->getStorage('user');
}
/**
* Creates a new instance of the Notify class.
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The container interface.
* @param array $configuration
* An array of configuration values for the plugin.
* @param string $plugin_id
* The plugin ID.
* @param mixed $plugin_definition
* The plugin definition.
*
* @return \Drupal\your_module\Notify
* The new instance of the Notify class.
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): Notify {
return new static(
$configuration,
......@@ -57,7 +96,8 @@ class Notify extends ConfigurableActionBase implements ContainerFactoryPluginInt
$plugin_definition,
$container->get('push_framework.channel.plugin.manager'),
$container->get('entity_type.bundle.info'),
$container->get('current_user')
$container->get('current_user'),
$container->get('entity_type.manager')
);
}
......@@ -88,8 +128,7 @@ class Notify extends ConfigurableActionBase implements ContainerFactoryPluginInt
public function execute(): void {
/** @var \Drupal\push_framework\ChannelPluginInterface $channelPlugin */
$channelPlugin = $this->channelPluginManager->createInstance($this->configuration['channel']);
/** @var \Drupal\user\Entity\User $user */
$user = User::load($this->currentUser->id());
$user = $this->userStorage->load($this->currentUser->id());
/** @var \Drupal\node\Entity\Node $node */
$node = Node::create([
'type' => $this->configuration['node_type'],
......
......@@ -3,10 +3,10 @@
namespace Drupal\push_framework\Plugin\DanseRecipientSelection;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\push_framework\ChannelPluginInterface;
use Drupal\push_framework\ChannelPluginManager;
use Drupal\danse\PayloadInterface;
use Drupal\danse\RecipientSelectionBase;
use Drupal\push_framework\ChannelPluginInterface;
use Drupal\push_framework\ChannelPluginManager;
use Drupal\push_framework\SourcePluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......
......@@ -2,9 +2,9 @@
namespace Drupal\push_framework\Plugin\migrate\destination;
use Drupal\migrate\Row;
use Drupal\push_framework\Service;
use Drupal\user\Plugin\migrate\destination\UserData;
use Drupal\migrate\Row;
/**
* Migration destination plugin to store push blocks as user data.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment