Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
commerce_stock_notifications
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
commerce_stock_notifications
Merge requests
!7
Issue
#3337086
by taraskorpach: Fixed passed items to the queue
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Issue
#3337086
by taraskorpach: Fixed passed items to the queue
issue/commerce_stock_notifications-3337086:8.x-1.x
into
8.x-1.x
Overview
0
Commits
1
Pipelines
0
Changes
3
Open
Taras Korpach
requested to merge
issue/commerce_stock_notifications-3337086:8.x-1.x
into
8.x-1.x
2 years ago
Overview
0
Commits
1
Pipelines
0
Changes
3
Expand
0
0
Merge request reports
Compare
8.x-1.x
version 1
68f17460
2 years ago
8.x-1.x (base)
and
latest version
latest version
22263302
1 commit,
2 years ago
version 1
68f17460
1 commit,
2 years ago
3 files
+
119
−
41
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
src/Plugin/QueueWorker/CommerceStockNotificationPurgeQueue.php
+
46
−
2
Options
@@ -2,7 +2,11 @@
namespace
Drupal\commerce_stock_notifications\Plugin\QueueWorker
;
use
Drupal\commerce_stock_notifications
\Entity\StockNotificationInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Plugin\ContainerFactoryPluginInterface
;
use
Drupal\Core\Queue\QueueWorkerBase
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Sends out notifications when items are in stock.
@@ -13,13 +17,53 @@ use Drupal\Core\Queue\QueueWorkerBase;
* cron = {"time" = 240}
* )
*/
class
CommerceStockNotificationPurgeQueue
extends
QueueWorkerBase
{
class
CommerceStockNotificationPurgeQueue
extends
QueueWorkerBase
implements
ContainerFactoryPluginInterface
{
/**
* The notification storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected
$notificationStorage
;
/**
* Constructs a new CommerceStockNotificationPurgeQueue object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The pluginId for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
EntityTypeManagerInterface
$entity_type_manager
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
);
$this
->
notificationStorage
=
$entity_type_manager
->
getStorage
(
'commerce_stock_notification'
);
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
,
array
$configuration
,
$plugin_id
,
$plugin_definition
)
{
return
new
static
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$container
->
get
(
'entity_type.manager'
)
);
}
/**
* {@inheritdoc}
*/
public
function
processItem
(
$data
)
{
$data
->
delete
();
$notification
=
$this
->
notificationStorage
->
load
(
$data
);
if
(
$notification
instanceof
StockNotificationInterface
)
{
$notification
->
delete
();
}
}
}
Loading