Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
composer_deploy
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
composer_deploy
Merge requests
!10
Fix CS
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Fix CS
issue/composer_deploy-3245516:3245516-cs
into
8.x-1.x
Overview
0
Commits
1
Pipelines
1
Changes
3
Open
Florian Weber
requested to merge
issue/composer_deploy-3245516:3245516-cs
into
8.x-1.x
6 months ago
Overview
0
Commits
1
Pipelines
1
Changes
3
Expand
Closes
#3245516
0
0
Merge request reports
Compare
8.x-1.x
8.x-1.x (HEAD)
and
latest version
latest version
9caa90ce
1 commit,
6 months ago
3 files
+
41
−
33
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
src/ComposerDeployHandler.php
+
21
−
20
Options
<?php
/**
* @file
* Contains \Drupal\composer_deploy\ComposerDeployHandler.
*/
namespace
Drupal\composer_deploy
;
use
DrupalFinder\DrupalFinderComposerRuntime
;
use
Symfony\Component\Filesystem\Path
;
/**
* Load package metadata from composers installed.json file.
*
* @internal
*/
class
ComposerDeployHandler
{
protected
$packages
=
[];
/**
*
List of package prefix
es.
*
Installed composer packag
es.
*
* @var
string[]
* @var
array
*/
protected
$prefixes
=
[
'drupal'
];
protected
array
$packages
=
[
];
/**
* @var \DrupalFinder\DrupalFinder
* List of package prefixes.
*
* @var string[]
*/
protected
$drupalFinder
;
public
function
__construct
(
DrupalFinderComposerRuntime
$drupalFinder
)
{
$this
->
drupalFinder
=
$drupalFinder
;
protected
array
$prefixes
=
[
'drupal'
];
public
function
__construct
(
protected
DrupalFinderComposerRuntime
$drupalFinder
)
{
$packages
=
json_decode
(
file_get_contents
(
$this
->
drupalFinder
->
getVendorDir
()
.
'/composer/installed.json'
),
TRUE
);
// Composer 2.0 compatibility.
// @see https://getcomposer.org/upgrade/UPGRADE-2.0.md
@@ -40,9 +35,11 @@ class ComposerDeployHandler {
}
/**
* Lookup package metadata by project name.
*
* @deprecated. Use \Drupal\composer_deploy\ComposerDeployHandler::getPackageByPath instead.
*/
public
function
getPackage
(
$projectName
)
{
public
function
getPackage
(
string
$projectName
)
:
?array
{
foreach
(
$this
->
packages
as
$package
)
{
foreach
(
$this
->
prefixes
as
$prefix
)
{
if
(
$package
[
'name'
]
==
$prefix
.
'/'
.
$projectName
)
{
@@ -50,10 +47,13 @@ class ComposerDeployHandler {
}
}
}
return
FALSE
;
return
NULL
;
}
public
function
getPackageByPath
(
$path
)
{
/**
* Lookup package metadata by path.
*/
public
function
getPackageByPath
(
string
$path
):
?array
{
foreach
(
$this
->
packages
as
$package
)
{
if
(
isset
(
$package
[
'install-path'
]))
{
$packagePath
=
$this
->
drupalFinder
->
getVendorDir
()
.
'/composer/'
.
$package
[
'install-path'
];
@@ -62,15 +62,16 @@ class ComposerDeployHandler {
}
}
}
return
FALSE
;
return
NULL
;
}
/**
* Set the package prefixes to check against.
*
* @param string[] $prefixes
* Composer vendor prefixes.
*/
public
function
setPrefixes
(
array
$prefixes
)
{
public
function
setPrefixes
(
array
$prefixes
)
:
void
{
$this
->
prefixes
=
$prefixes
;
}
Loading