Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
305ed676
Commit
305ed676
authored
Jan 19, 2015
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2205271
by trobey, jhedstrom: Project namespace for dependencies
parent
02d58f6a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
3 deletions
+47
-3
core/lib/Drupal/Core/Extension/InfoParserInterface.php
core/lib/Drupal/Core/Extension/InfoParserInterface.php
+10
-1
core/lib/Drupal/Core/Extension/ModuleHandler.php
core/lib/Drupal/Core/Extension/ModuleHandler.php
+12
-2
core/modules/system/src/Tests/Module/DependencyTest.php
core/modules/system/src/Tests/Module/DependencyTest.php
+16
-0
core/modules/system/tests/modules/system_project_namespace_test/system_project_namespace_test.info.yml
...ect_namespace_test/system_project_namespace_test.info.yml
+8
-0
core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
+1
-0
No files found.
core/lib/Drupal/Core/Extension/InfoParserInterface.php
View file @
305ed676
...
...
@@ -27,7 +27,16 @@ interface InfoParserInterface {
* - type: whether it is for a module or theme. (Required)
*
* Information stored in a module .info.yml file:
* - dependencies: An array of shortnames of other modules this module requires.
* - dependencies: An array of dependency strings. Each is in the form
* 'project:module (versions)'; with the following meanings:
* - project: (optional) Project shortname, recommended to ensure
* uniqueness, if the module is part of a project hosted on drupal.org.
* If omitted, also omit the : that follows. The project name is currently
* ignored by Drupal core but is used for automated testing.
* - module: (required) Module shortname within the project.
* - (versions): Version information, consisting of one or more
* comma-separated operator/value pairs or simply version numbers, which
* can contain "x" as a wildcard. Examples: (>=8.22, <8.28), (8.x-3.x).
* - package: The name of the package of modules this module belongs to.
*
* See forum.info.yml for an example of a module .info.yml file.
...
...
core/lib/Drupal/Core/Extension/ModuleHandler.php
View file @
305ed676
...
...
@@ -631,7 +631,12 @@ protected function verifyImplementations(&$implementations, $hook) {
* Parses a dependency for comparison by drupal_check_incompatibility().
*
* @param $dependency
* A dependency string, for example 'foo (>=8.x-4.5-beta5, 3.x)'.
* A dependency string, which specifies a module dependency, and optionally
* the project it comes from and versions that are supported. Supported
* formats include:
* - 'module'
* - 'project:module'
* - 'project:module (>=version, version)'
*
* @return
* An associative array with three keys:
...
...
@@ -646,6 +651,12 @@ protected function verifyImplementations(&$implementations, $hook) {
* @see drupal_check_incompatibility()
*/
public
static
function
parseDependency
(
$dependency
)
{
$value
=
array
();
// Split out the optional project name.
if
(
strpos
(
$dependency
,
':'
)
!==
FALSE
)
{
list
(
$project_name
,
$dependency
)
=
explode
(
':'
,
$dependency
);
$value
[
'project'
]
=
$project_name
;
}
// We use named subpatterns and support every op that version_compare
// supports. Also, op is optional and defaults to equals.
$p_op
=
'(?<operation>!=|==|=|<|<=|>|>=|<>)?'
;
...
...
@@ -654,7 +665,6 @@ public static function parseDependency($dependency) {
$p_major
=
'(?<major>\d+)'
;
// By setting the minor version to x, branches can be matched.
$p_minor
=
'(?<minor>(?:\d+|x)(?:-[A-Za-z]+\d+)?)'
;
$value
=
array
();
$parts
=
explode
(
'('
,
$dependency
,
2
);
$value
[
'name'
]
=
trim
(
$parts
[
0
]);
if
(
isset
(
$parts
[
1
]))
{
...
...
core/modules/system/src/Tests/Module/DependencyTest.php
View file @
305ed676
...
...
@@ -14,6 +14,22 @@
* @group Module
*/
class
DependencyTest
extends
ModuleTestBase
{
/**
* Checks functionality of project namespaces for dependencies.
*/
function
testProjectNamespaceForDependencies
()
{
$edit
=
array
(
'modules[Core][filter][enable]'
=>
TRUE
,
);
$this
->
drupalPostForm
(
'admin/modules'
,
$edit
,
t
(
'Save configuration'
));
// Enable module with project namespace to ensure nothing breaks.
$edit
=
array
(
'modules[Testing][system_project_namespace_test][enable]'
=>
TRUE
,
);
$this
->
drupalPostForm
(
'admin/modules'
,
$edit
,
t
(
'Save configuration'
));
$this
->
assertModules
(
array
(
'system_project_namespace_test'
),
TRUE
);
}
/**
* Attempts to enable the Content Translation module without Language enabled.
*/
...
...
core/modules/system/tests/modules/system_project_namespace_test/system_project_namespace_test.info.yml
0 → 100644
View file @
305ed676
name
:
'
System
project
namespace'
type
:
module
description
:
'
Support
module
for
testing
project
namespace
system
dependencies.'
package
:
Testing
version
:
VERSION
core
:
8.x
dependencies
:
-
drupal:filter
core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
View file @
305ed676
...
...
@@ -499,6 +499,7 @@ public function dependencyProvider() {
array
(
'views_ui(<= 8.x-1.x)'
,
array
(
'name'
=>
'views_ui'
,
'original_version'
=>
' (<= 8.x-1.x)'
,
'versions'
=>
array
(
array
(
'op'
=>
'<='
,
'version'
=>
'2.x'
)))),
array
(
'views_ui( <=8.x-1.x)'
,
array
(
'name'
=>
'views_ui'
,
'original_version'
=>
' ( <=8.x-1.x)'
,
'versions'
=>
array
(
array
(
'op'
=>
'<='
,
'version'
=>
'2.x'
)))),
array
(
'views_ui(>8.x-1.x)'
,
array
(
'name'
=>
'views_ui'
,
'original_version'
=>
' (>8.x-1.x)'
,
'versions'
=>
array
(
array
(
'op'
=>
'>'
,
'version'
=>
'2.x'
)))),
array
(
'drupal:views_ui(>8.x-1.x)'
,
array
(
'project'
=>
'drupal'
,
'name'
=>
'views_ui'
,
'original_version'
=>
' (>8.x-1.x)'
,
'versions'
=>
array
(
array
(
'op'
=>
'>'
,
'version'
=>
'2.x'
)))),
);
}
...
...
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