Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
deck-web
Model Event
Commits
efa23105
Commit
efa23105
authored
3 months ago
by
Ильнур Табулдин
☠
Browse files
Options
Download
Email Patches
Plain Diff
Добавлено управление controllerMap
parent
8a02036b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/handle/EventQueue.php
+29
-0
src/handle/EventQueue.php
with
29 additions
and
0 deletions
+29
-0
src/handle/EventQueue.php
+
29
-
0
View file @
efa23105
...
...
@@ -5,7 +5,9 @@ namespace deck\ModelEvent\handle;
use
PhpAmqpLib\Connection\AbstractConnection
;
use
PhpAmqpLib\Connection\Heartbeat\PCNTLHeartbeatSender
;
use
Yii
;
use
yii\base\InvalidConfigException
;
use
yii\di\Instance
;
use
yii\helpers\Inflector
;
use
yii\helpers\VarDumper
;
use
yii\queue\amqp_interop
\
Queue
as
OriginalQueue
;
use
yii\queue\InvalidJobException
;
...
...
@@ -22,6 +24,8 @@ class EventQueue extends OriginalQueue
public
$serializer
=
EventHandlerSerializer
::
class
;
/** @var EventHandlerFactoryInterface $handlerFactory */
public
$handlerFactory
;
/** @var ?string $moduleName */
public
$moduleName
=
null
;
public
function
init
()
{
...
...
@@ -93,4 +97,29 @@ class EventQueue extends OriginalQueue
$this
->
sender
->
unregister
();
}
}
protected
function
getCommandId
()
{
if
(
$this
->
moduleName
===
null
)
{
return
parent
::
getCommandId
();
}
foreach
(
Yii
::
$app
->
getModule
(
$this
->
moduleName
)
->
getComponents
(
false
)
as
$id
=>
$component
)
{
if
(
$component
===
$this
)
{
return
Inflector
::
camel2id
(
$id
);
}
}
throw
new
InvalidConfigException
(
"Queue must be an
$this->moduleName
component."
);
}
public
function
bootstrap
(
$app
)
{
if
(
$this
->
moduleName
===
null
)
{
parent
::
bootstrap
(
$app
);
}
else
{
$app
->
getModule
(
$this
->
moduleName
)
->
controllerMap
[
$this
->
getCommandId
()]
=
[
'class'
=>
$this
->
commandClass
,
'queue'
=>
$this
]
+
$this
->
commandOptions
;
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help