Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
discord_php
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
discord_php
Merge requests
!1
Resolve
#3444582
"Version 2.0.x for"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve
#3444582
"Version 2.0.x for"
issue/discord_php-3444582:3444582-version-2.0.x-for
into
2.0.x
Overview
0
Commits
25
Pipelines
18
Changes
19
Merged
Jasper Lammens
requested to merge
issue/discord_php-3444582:3444582-version-2.0.x-for
into
2.0.x
1 year ago
Overview
0
Commits
25
Pipelines
18
Changes
19
Expand
Closes
#3444582
0
0
Merge request reports
Compare
2.0.x
version 17
fb680eaa
11 months ago
version 16
195df692
1 year ago
version 15
889687c8
1 year ago
version 14
6107c617
1 year ago
version 13
cd9faa5c
1 year ago
version 12
2772b8d1
1 year ago
version 11
8959f897
1 year ago
version 10
aa27d5d7
1 year ago
version 9
83a51a3b
1 year ago
version 8
5f33f3d0
1 year ago
version 7
801cc676
1 year ago
version 6
2ede3ae2
1 year ago
version 5
a0c8e311
1 year ago
version 4
aa8f5b94
1 year ago
version 3
72c37d84
1 year ago
version 2
330acf9a
1 year ago
version 1
1ef7fc5f
1 year ago
2.0.x (base)
and
latest version
latest version
fb680eaa
25 commits,
11 months ago
version 17
fb680eaa
25 commits,
11 months ago
version 16
195df692
24 commits,
1 year ago
version 15
889687c8
23 commits,
1 year ago
version 14
6107c617
22 commits,
1 year ago
version 13
cd9faa5c
21 commits,
1 year ago
version 12
2772b8d1
20 commits,
1 year ago
version 11
8959f897
19 commits,
1 year ago
version 10
aa27d5d7
17 commits,
1 year ago
version 9
83a51a3b
15 commits,
1 year ago
version 8
5f33f3d0
13 commits,
1 year ago
version 7
801cc676
11 commits,
1 year ago
version 6
2ede3ae2
9 commits,
1 year ago
version 5
a0c8e311
7 commits,
1 year ago
version 4
aa8f5b94
6 commits,
1 year ago
version 3
72c37d84
5 commits,
1 year ago
version 2
330acf9a
4 commits,
1 year ago
version 1
1ef7fc5f
3 commits,
1 year ago
19 files
+
428
−
215
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
19
Search (e.g. *.vue) (Ctrl+P)
modules/eca/src/EventSubscriber/EcaEventSubscriber.php deleted
100644 → 0
+
0
−
92
Options
<?php
namespace
Drupal\discord_php_eca\EventSubscriber
;
use
Drupal\Core\Logger\LoggerChannelInterface
;
use
Drupal\Core\TypedData\TypedDataManagerInterface
;
use
Drupal\Core\Utility\Error
;
use
Drupal\discord_php
\Event\MessageCreateEvent
;
use
Drupal\discord_php
\TypedData\Definition\MessageDefinition
;
use
Drupal\discord_php_eca
\Plugin\ECA\Event\EcaEvent
;
use
Drupal\eca\EcaEvents
;
use
Drupal\eca\Event\BeforeInitialExecutionEvent
;
use
Drupal\eca\EventSubscriber\EcaBase
;
use
Drupal\eca\Processor
;
use
Drupal\eca\Token\TokenInterface
;
use
Symfony\Component\Serializer\Exception\ExceptionInterface
;
use
Symfony\Component\Serializer\Normalizer\NormalizerInterface
;
/**
* Event subscriber for discord_php_eca.
*/
class
EcaEventSubscriber
extends
EcaBase
{
/**
* Constructs an EcaEventSubscriber instance.
*
* @param \Drupal\eca\Processor $processor
* The processor.
* @param \Drupal\eca\Token\TokenInterface $token_service
* The token service.
* @param \Drupal\Core\Logger\LoggerChannelInterface $logger
* The logger.
* @param \Symfony\Component\Serializer\Normalizer\NormalizerInterface $serializer
* The serializer.
* @param \Drupal\Core\TypedData\TypedDataManagerInterface $typedDataManager
* The typed data manager.
*/
public
function
__construct
(
Processor
$processor
,
TokenInterface
$token_service
,
protected
LoggerChannelInterface
$logger
,
protected
NormalizerInterface
$serializer
,
protected
TypedDataManagerInterface
$typedDataManager
)
{
parent
::
__construct
(
$processor
,
$token_service
);
}
/**
* Before the execution, find the events to intercept.
*
* @param \Drupal\eca\Event\BeforeInitialExecutionEvent $beforeEvent
* The event.
*/
public
function
onBeforeInitialExecution
(
BeforeInitialExecutionEvent
$beforeEvent
):
void
{
$event
=
$beforeEvent
->
getEvent
();
if
(
$event
instanceof
MessageCreateEvent
)
{
$definition
=
MessageDefinition
::
create
(
'discord_message'
);
$data
=
[];
try
{
$data
=
$this
->
typedDataManager
->
create
(
$definition
,
$this
->
serializer
->
normalize
(
$event
->
getMessage
())
);
}
catch
(
ExceptionInterface
$e
)
{
$this
->
logger
->
error
(
Error
::
DEFAULT_ERROR_MESSAGE
,
Error
::
decodeException
(
$e
));
}
$this
->
tokenService
->
addTokenData
(
'message'
,
$data
);
}
}
/**
* {@inheritdoc}
*/
public
static
function
getSubscribedEvents
():
array
{
$events
=
array_reduce
(
EcaEvent
::
definitions
(),
static
function
(
$events
,
$definition
)
{
$events
[
$definition
[
'event_name'
]][]
=
[
'onEvent'
];
return
$events
;
},
[]);
$events
[
EcaEvents
::
BEFORE_INITIAL_EXECUTION
][]
=
[
'onBeforeInitialExecution'
,
-
100
,
];
return
$events
;
}
}
Loading