Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
project_browser
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
project_browser
Commits
aabf5955
Commit
aabf5955
authored
4 months ago
by
Adam G-H
Committed by
Chris Wells
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3504781
: Profile should not be shown in drupal_core plugin
parent
22f457e3
No related branches found
No related tags found
1 merge request
!708
Refactor for clarity
Pipeline
#418248
passed
4 months ago
Stage: build
Stage: validate
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Plugin/ProjectBrowserSource/DrupalCore.php
+23
-44
23 additions, 44 deletions
src/Plugin/ProjectBrowserSource/DrupalCore.php
tests/src/Functional/EnabledSourceHandlerTest.php
+11
-1
11 additions, 1 deletion
tests/src/Functional/EnabledSourceHandlerTest.php
with
34 additions
and
45 deletions
src/Plugin/ProjectBrowserSource/DrupalCore.php
+
23
−
44
View file @
aabf5955
...
...
@@ -26,50 +26,14 @@ use Symfony\Component\HttpFoundation\RequestStack;
*/
final
class
DrupalCore
extends
ProjectBrowserSourceBase
{
/**
* All core modules are covered under security policy.
*
* @var string
*/
const
COVERED
=
'covered'
;
/**
* All core modules are "Active" modules.
*
* @var string
*/
const
ACTIVE
=
'active'
;
/**
* All core modules are "Maintained" modules.
*
* @var string
*/
const
MAINTAINED
=
'maintained'
;
/**
* Constructor for Drupal Core plugin.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
* The request from the browser.
* @param \Drupal\Core\Cache\CacheBackendInterface $cacheBin
* The cache back end interface.
* @param \Drupal\Core\Extension\ModuleExtensionList $moduleExtensionList
* The list of available modules.
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
private
readonly
RequestStack
$requestStack
,
private
readonly
CacheBackendInterface
$cacheBin
,
private
readonly
ModuleExtensionList
$moduleExtensionList
,
private
readonly
ModuleExtensionList
$moduleList
,
private
readonly
string
|
false
|
null
$installProfile
,
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
);
}
...
...
@@ -78,6 +42,9 @@ final class DrupalCore extends ProjectBrowserSourceBase {
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
,
array
$configuration
,
$plugin_id
,
$plugin_definition
):
static
{
$install_profile
=
$container
->
getParameter
(
'install_profile'
);
assert
(
is_string
(
$install_profile
)
||
$install_profile
===
FALSE
||
is_null
(
$install_profile
));
return
new
static
(
$configuration
,
$plugin_id
,
...
...
@@ -85,6 +52,7 @@ final class DrupalCore extends ProjectBrowserSourceBase {
$container
->
get
(
RequestStack
::
class
),
$container
->
get
(
'cache.project_browser'
),
$container
->
get
(
ModuleExtensionList
::
class
),
$install_profile
,
);
}
...
...
@@ -94,13 +62,24 @@ final class DrupalCore extends ProjectBrowserSourceBase {
* @return \Drupal\Core\Extension\Extension[]
* The array containing core modules, keyed by module machine name.
*/
protected
function
getCoreModules
()
{
$projects
=
array_filter
(
$this
->
moduleExtensionList
->
reset
()
->
getList
(),
fn
(
Extension
$project
):
bool
=>
$project
->
origin
===
'core'
);
$include_tests
=
Settings
::
get
(
'extension_discovery_scan_tests'
)
||
drupal_valid_test_ua
();
if
(
!
$include_tests
)
{
$projects
=
array_filter
(
$projects
,
fn
(
Extension
$project
):
bool
=>
empty
(
$project
->
info
[
'hidden'
])
&&
$project
->
info
[
'package'
]
!==
'Testing'
);
protected
function
getCoreModules
():
array
{
$modules
=
array_filter
(
$this
->
moduleList
->
reset
()
->
getList
(),
fn
(
Extension
$module
):
bool
=>
$module
->
origin
===
'core'
,
);
// Don't include the current install profile, if there is one.
if
(
$this
->
installProfile
)
{
unset
(
$modules
[
$this
->
installProfile
]);
}
return
$projects
;
// If we're including test modules, no further filtering is needed.
if
(
Settings
::
get
(
'extension_discovery_scan_tests'
)
||
drupal_valid_test_ua
())
{
return
$modules
;
}
// Only return non-hidden modules that aren't in the `Testing` package.
return
array_filter
(
$modules
,
fn
(
Extension
$module
):
bool
=>
empty
(
$module
->
info
[
'hidden'
])
&&
$module
->
info
[
'package'
]
!==
'Testing'
,
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
tests/src/Functional/EnabledSourceHandlerTest.php
+
11
−
1
View file @
aabf5955
...
...
@@ -32,7 +32,7 @@ class EnabledSourceHandlerTest extends BrowserTestBase {
parent
::
setUp
();
$this
->
config
(
'project_browser.admin_settings'
)
->
set
(
'enabled_sources'
,
[
'project_browser_test_mock'
])
->
set
(
'enabled_sources'
,
[
'project_browser_test_mock'
,
'drupal_core'
])
->
save
(
TRUE
);
}
...
...
@@ -129,4 +129,14 @@ class EnabledSourceHandlerTest extends BrowserTestBase {
return
$status
->
isInitialized
(
$project
)
&&
$commands
->
isInitialized
(
$project
);
}
/**
* Tests that the install profile is ignored by the drupal_core source.
*/
public
function
testProfileNotListedByCoreSource
():
void
{
$projects
=
$this
->
container
->
get
(
EnabledSourceHandler
::
class
)
->
getProjects
(
'drupal_core'
);
$this
->
assertNotEmpty
(
$projects
);
// Assert that the current install profile is not returned by the source.
$this
->
assertNotContains
(
$this
->
profile
,
array_column
(
reset
(
$projects
)
->
list
,
'machineName'
));
}
}
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