Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Issue forks
queue_order-3224274
Commits
0382e78b
Commit
0382e78b
authored
Mar 10, 2018
by
voleger
Browse files
Add correct implementation of DI
parent
76a6cd9e
Changes
3
Hide whitespace changes
Inline
Side-by-side
queue_order.info.yml
View file @
0382e78b
name
:
Queue order
[no UI]
name
:
"
Queue
order
"
type
:
module
description
:
"
Provide
api
to
control
queue
order
execution"
package
:
System utility
description
:
"
Provide
basic
functionality
to
control
queue
order
execution"
package
:
"
System
utility
"
core
:
8.x
dependencies
:
-
drupal:system
(>= 8.2.0)
-
drupal:system
src/Queue/QueueWorkerManager.php
View file @
0382e78b
...
...
@@ -3,6 +3,9 @@
namespace
Drupal\queue_order\Queue
;
use
Drupal\Component\Utility\SortArray
;
use
Drupal\Core\Cache\CacheBackendInterface
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\Extension\ModuleHandlerInterface
;
use
Drupal\Core\Queue\QueueWorkerManager
as
CoreQueueWorkerManager
;
/**
...
...
@@ -12,12 +15,37 @@ use Drupal\Core\Queue\QueueWorkerManager as CoreQueueWorkerManager;
*/
class
QueueWorkerManager
extends
CoreQueueWorkerManager
{
/**
* The module config.
*
* @var \Drupal\Core\Config\ImmutableConfig
*/
protected
$config
;
/**
* Constructs an QueueWorkerManager object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config
* The module configs.
*/
public
function
__construct
(
\
Traversable
$namespaces
,
CacheBackendInterface
$cache_backend
,
ModuleHandlerInterface
$module_handler
,
ConfigFactoryInterface
$config
)
{
parent
::
__construct
(
$namespaces
,
$cache_backend
,
$module_handler
);
$this
->
config
=
$config
->
get
(
'queue_order.settings'
);
}
/**
* {@inheritdoc}
*/
public
function
getDefinitions
()
{
$definitions
=
parent
::
getDefinitions
();
$weight
=
\
Drupal
::
config
(
'queue_order.settings'
)
->
get
(
'order'
);
$weight
=
$this
->
config
->
get
(
'order'
);
$weight
=
empty
(
$weight
)
?
[]
:
$weight
;
foreach
(
$definitions
as
$key
=>
&
$definition
)
{
$definition
[
'weight'
]
=
empty
(
$weight
[
$key
])
?
0
:
intval
(
$weight
[
$key
]);
...
...
src/QueueOrderServiceProvider.php
View file @
0382e78b
...
...
@@ -5,6 +5,7 @@ namespace Drupal\queue_order;
use
Drupal\Core\DependencyInjection\ContainerBuilder
;
use
Drupal\Core\DependencyInjection\ServiceProviderBase
;
use
Drupal\queue_order
\
Queue\QueueWorkerManager
;
use
Symfony\Component\DependencyInjection\Reference
;
/**
* Class QueueOrderServiceProvider.
...
...
@@ -18,8 +19,9 @@ class QueueOrderServiceProvider extends ServiceProviderBase {
*/
public
function
alter
(
ContainerBuilder
$container
)
{
if
(
$container
->
has
(
'plugin.manager.queue_worker'
))
{
$container
->
getDefinition
(
'plugin.manager.queue_worker'
)
->
setClass
(
QueueWorkerManager
::
class
);
$plugin_manager
=
$container
->
getDefinition
(
'plugin.manager.queue_worker'
);
$plugin_manager
->
setClass
(
QueueWorkerManager
::
class
);
$plugin_manager
->
addArgument
(
new
Reference
(
'config.factory'
));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment