Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
advancedqueue
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
advancedqueue
Commits
0488faec
Commit
0488faec
authored
8 months ago
by
Bohdan Mykhalchuk
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3323520
: Create a way to empty a queue
parent
30449cf1
No related branches found
No related tags found
1 merge request
!20
Issue #3323520: Create a way to empty a queue
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
drush.services.yml
+1
-1
1 addition, 1 deletion
drush.services.yml
src/Commands/AdvancedQueueCommands.php
+39
-1
39 additions, 1 deletion
src/Commands/AdvancedQueueCommands.php
with
40 additions
and
2 deletions
drush.services.yml
+
1
−
1
View file @
0488faec
services
:
services
:
advancedqueue.commands
:
advancedqueue.commands
:
class
:
\Drupal\advancedqueue\Commands\AdvancedQueueCommands
class
:
\Drupal\advancedqueue\Commands\AdvancedQueueCommands
arguments
:
[
'
@entity_type.manager'
,
'
@advancedqueue.processor'
]
arguments
:
[
'
@entity_type.manager'
,
'
@advancedqueue.processor'
,
'
@database'
]
tags
:
tags
:
-
{
name
:
drush.command
}
-
{
name
:
drush.command
}
This diff is collapsed.
Click to expand it.
src/Commands/AdvancedQueueCommands.php
+
39
−
1
View file @
0488faec
...
@@ -5,6 +5,7 @@ namespace Drupal\advancedqueue\Commands;
...
@@ -5,6 +5,7 @@ namespace Drupal\advancedqueue\Commands;
use
Consolidation\OutputFormatters\StructuredData\RowsOfFields
;
use
Consolidation\OutputFormatters\StructuredData\RowsOfFields
;
use
Drupal\advancedqueue\Job
;
use
Drupal\advancedqueue\Job
;
use
Drupal\advancedqueue\ProcessorInterface
;
use
Drupal\advancedqueue\ProcessorInterface
;
use
Drupal\Core\Database\Connection
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\StringTranslation\TranslatableMarkup
;
use
Drupal\Core\StringTranslation\TranslatableMarkup
;
use
Drush\Commands\DrushCommands
;
use
Drush\Commands\DrushCommands
;
...
@@ -28,6 +29,13 @@ class AdvancedQueueCommands extends DrushCommands {
...
@@ -28,6 +29,13 @@ class AdvancedQueueCommands extends DrushCommands {
*/
*/
protected
$processor
;
protected
$processor
;
/**
* The database connection.
*
* @var \Drupal\Core\Database\Connection
*/
protected
$connection
;
/**
/**
* Constructs a new AdvancedQueueCommands object.
* Constructs a new AdvancedQueueCommands object.
*
*
...
@@ -36,11 +44,12 @@ class AdvancedQueueCommands extends DrushCommands {
...
@@ -36,11 +44,12 @@ class AdvancedQueueCommands extends DrushCommands {
* @param \Drupal\advancedqueue\ProcessorInterface $processor
* @param \Drupal\advancedqueue\ProcessorInterface $processor
* The queue processor.
* The queue processor.
*/
*/
public
function
__construct
(
EntityTypeManagerInterface
$entity_type_manager
,
ProcessorInterface
$processor
)
{
public
function
__construct
(
EntityTypeManagerInterface
$entity_type_manager
,
ProcessorInterface
$processor
,
Connection
$connection
)
{
parent
::
__construct
();
parent
::
__construct
();
$this
->
entityTypeManager
=
$entity_type_manager
;
$this
->
entityTypeManager
=
$entity_type_manager
;
$this
->
processor
=
$processor
;
$this
->
processor
=
$processor
;
$this
->
connection
=
$connection
;
}
}
/**
/**
...
@@ -135,4 +144,33 @@ class AdvancedQueueCommands extends DrushCommands {
...
@@ -135,4 +144,33 @@ class AdvancedQueueCommands extends DrushCommands {
return
new
RowsOfFields
(
$rows
);
return
new
RowsOfFields
(
$rows
);
}
}
/**
* Clear a queue.
*
* @param string $queue_id
* The queue ID.
*
* @throws \Exception
*
* @command advancedqueue:queue:clear
* @usage advancedqueue:queue:clear commerce_recurring
*/
public
function
clear
(
$queue_id
)
{
if
(
$this
->
io
()
->
confirm
(
dt
(
"Are you sure you want to remove queue items for the the @queue_id queue?"
,
[
'@queue_id'
=>
$queue_id
])))
{
$queue_storage
=
$this
->
entityTypeManager
->
getStorage
(
'advancedqueue_queue'
);
/** @var \Drupal\advancedqueue\Entity\QueueInterface $queue */
$queue
=
$queue_storage
->
load
(
$queue_id
);
if
(
!
$queue
)
{
throw
new
\Exception
(
dt
(
'Could not find queue "@queue_id".'
,
[
'@queue_id'
=>
$queue_id
]));
}
$this
->
connection
->
delete
(
'advancedqueue'
)
->
condition
(
'queue_id'
,
$queue_id
)
->
execute
();
$this
->
io
()
->
success
(
dt
(
'The queue items for the the @queue queue have been deleted.'
,
[
'@queue'
=>
$queue
->
label
(),
]));
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment