Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
composer.json Utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Composer
library
composer.json Utils
Commits
afa504b9
Commit
afa504b9
authored
6 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
Build interface for BaseHandler
Add method to determine if process runs in a CI/CD context
parent
2bf8c7ae
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
BaseHandler.php
+15
-19
15 additions, 19 deletions
BaseHandler.php
BaseHandlerInterface.php
+34
-0
34 additions, 0 deletions
BaseHandlerInterface.php
with
49 additions
and
19 deletions
BaseHandler.php
+
15
−
19
View file @
afa504b9
...
...
@@ -10,7 +10,7 @@ use Composer\IO\IOInterface;
*
* @package LakeDrops\Component\Composer
*/
abstract
class
BaseHandler
{
abstract
class
BaseHandler
implements
BaseHandlerInterface
{
/**
* The composer object of this session.
...
...
@@ -47,12 +47,9 @@ abstract class BaseHandler {
}
/**
* Look up the Drupal core package object.
*
* @return \Composer\Package\PackageInterface
* The Drupal core package.
* {@inheritdoc}
*/
p
rotected
function
getDrupalCorePackage
()
{
p
ublic
function
getDrupalCorePackage
()
{
if
(
!
isset
(
$this
->
drupalCorePackage
))
{
$this
->
drupalCorePackage
=
$this
->
getPackage
(
'drupal/core'
);
}
...
...
@@ -60,25 +57,24 @@ abstract class BaseHandler {
}
/**
* Retrieve a package from the current composer process.
*
* @param string $name
* Name of the package to get from the current composer installation.
*
* @return \Composer\Package\PackageInterface
* The package.
* {@inheritdoc}
*/
p
rotected
function
getPackage
(
$name
)
{
p
ublic
function
getPackage
(
$name
)
{
return
$this
->
composer
->
getRepositoryManager
()
->
getLocalRepository
()
->
findPackage
(
$name
,
'*'
);
}
/**
* Wrapper for git command in the root directory.
*
* @param string $command
* Git command name, arguments and/or options.
* {@inheritdoc}
*/
public
function
isCiContext
()
{
$ci_project_dir
=
getenv
(
'CI_PROJECT_DIR'
);
return
!
empty
(
$ci_project_dir
);
}
/**
* {@inheritdoc}
*/
p
rotected
function
git
(
$command
)
{
p
ublic
function
git
(
$command
)
{
passthru
(
escapeshellcmd
(
'git -c "user.email=composer@lakedrops.com" '
.
$command
));
}
...
...
This diff is collapsed.
Click to expand it.
BaseHandlerInterface.php
+
34
−
0
View file @
afa504b9
...
...
@@ -9,4 +9,38 @@ namespace LakeDrops\Component\Composer;
*/
interface
BaseHandlerInterface
{
/**
* Look up the Drupal core package object.
*
* @return \Composer\Package\PackageInterface
* The Drupal core package.
*/
public
function
getDrupalCorePackage
();
/**
* Retrieve a package from the current composer process.
*
* @param string $name
* Name of the package to get from the current composer installation.
*
* @return \Composer\Package\PackageInterface
* The package.
*/
public
function
getPackage
(
$name
);
/**
* Determine if the current process runs in a CI/CD context.
*
* @return bool
*/
public
function
isCiContext
();
/**
* Wrapper for git command in the root directory.
*
* @param string $command
* Git command name, arguments and/or options.
*/
public
function
git
(
$command
);
}
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