Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automatic_updates
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
automatic_updates
Commits
4fd5ec3e
Commit
4fd5ec3e
authored
3 years ago
by
Ted Bowman
Committed by
Adam G-H
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3231153
by tedbow: Simplify event dispatching in the updater
parent
b7ff1c56
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!29
Issue #3231153: Simplify dispatching
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Updater.php
+6
-15
6 additions, 15 deletions
src/Updater.php
with
6 additions
and
15 deletions
src/Updater.php
+
6
−
15
View file @
4fd5ec3e
...
...
@@ -25,16 +25,6 @@ class Updater {
use
StringTranslationTrait
;
/**
* The event classes to dispatch for various update events.
*
* @var string[]
*/
protected
const
EVENT_CLASSES
=
[
AutomaticUpdatesEvents
::
PRE_START
=>
PreStartEvent
::
class
,
AutomaticUpdatesEvents
::
PRE_COMMIT
=>
PreCommitEvent
::
class
,
];
/**
* The state key in which to store the status of the update.
*
...
...
@@ -178,7 +168,8 @@ class Updater {
}
$packages
[]
=
'drupal/core:'
.
$project_versions
[
'drupal'
];
$stage_key
=
$this
->
createActiveStage
(
$packages
);
$event
=
$this
->
dispatchUpdateEvent
(
AutomaticUpdatesEvents
::
PRE_START
);
/** @var \Drupal\automatic_updates\Event\PreStartEvent $event */
$event
=
$this
->
dispatchUpdateEvent
(
new
PreStartEvent
(),
AutomaticUpdatesEvents
::
PRE_START
);
$this
->
beginner
->
begin
(
static
::
getActiveDirectory
(),
static
::
getStageDirectory
(),
$this
->
getExclusions
(
$event
));
return
$stage_key
;
}
...
...
@@ -224,7 +215,7 @@ class Updater {
*/
public
function
commit
():
void
{
/** @var \Drupal\automatic_updates\Event\PreCommitEvent $event */
$event
=
$this
->
dispatchUpdateEvent
(
AutomaticUpdatesEvents
::
PRE_COMMIT
);
$event
=
$this
->
dispatchUpdateEvent
(
new
PreCommitEvent
(),
AutomaticUpdatesEvents
::
PRE_COMMIT
);
// @todo Pass excluded paths into the committer once
// https://github.com/php-tuf/composer-stager/pull/14 is in a tagged release
// of Composer Stager.
...
...
@@ -278,6 +269,8 @@ class Updater {
/**
* Dispatches an update event.
*
* @param \Drupal\automatic_updates\Event\UpdateEvent $event
* The update event.
* @param string $event_name
* The name of the event to dispatch.
*
...
...
@@ -287,9 +280,7 @@ class Updater {
* @throws \Drupal\automatic_updates\Exception\UpdateException
* If any of the event subscribers adds a validation error.
*/
public
function
dispatchUpdateEvent
(
string
$event_name
):
UpdateEvent
{
$class
=
static
::
EVENT_CLASSES
[
$event_name
]
??
UpdateEvent
::
class
;
$event
=
new
$class
();
public
function
dispatchUpdateEvent
(
UpdateEvent
$event
,
string
$event_name
):
UpdateEvent
{
$this
->
eventDispatcher
->
dispatch
(
$event
,
$event_name
);
if
(
$checker_results
=
$event
->
getResults
(
SystemManager
::
REQUIREMENT_ERROR
))
{
throw
new
UpdateException
(
$checker_results
,
...
...
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