Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automatic_updates-3449631
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
automatic_updates-3449631
Commits
70ef2270
Commit
70ef2270
authored
3 years ago
by
Adam G-H
Committed by
Ted Bowman
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3228521
by phenaproxima: Clean up ProcessFactory
parent
7886fa92
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
src/ComposerStager/ProcessFactory.php
+39
-18
39 additions, 18 deletions
src/ComposerStager/ProcessFactory.php
src/Updater.php
+0
-33
0 additions, 33 deletions
src/Updater.php
with
39 additions
and
51 deletions
src/ComposerStager/ProcessFactory.php
+
39
−
18
View file @
70ef2270
...
...
@@ -2,9 +2,8 @@
namespace
Drupal\automatic_updates\ComposerStager
;
use
PhpTuf\ComposerStager\
Exception\LogicException
;
use
PhpTuf\ComposerStager\
Infrastructure\Process\ProcessFactory
as
StagerProcessFactory
;
use
PhpTuf\ComposerStager\Infrastructure\Process\ProcessFactoryInterface
;
use
Symfony\Component\Process\Exception\ExceptionInterface
;
use
Symfony\Component\Process\Process
;
/**
...
...
@@ -14,27 +13,49 @@ use Symfony\Component\Process\Process;
*/
final
class
ProcessFactory
implements
ProcessFactoryInterface
{
/**
* The decorated process factory.
*
* @var \PhpTuf\ComposerStager\Infrastructure\Process\ProcessFactoryInterface
*/
private
$decorated
;
/**
* Constructs a ProcessFactory object.
*/
public
function
__construct
()
{
$this
->
decorated
=
new
StagerProcessFactory
();
}
/**
* Returns the value of an environment variable.
*
* @param string $variable
* The name of the variable.
*
* @return mixed
* The value of the variable.
*/
private
function
getEnv
(
string
$variable
)
{
if
(
function_exists
(
'apache_getenv'
))
{
return
apache_getenv
(
$variable
);
}
return
getenv
(
$variable
);
}
/**
* {@inheritdoc}
*/
public
function
create
(
array
$command
):
Process
{
try
{
if
(
$this
->
isComposerCommand
(
$command
))
{
$process
=
new
Process
(
$command
,
NULL
,
[
'COMPOSER_HOME'
=>
$this
->
getComposerHomePath
()]);
$path
=
function_exists
(
'apache_getenv'
)
?
apache_getenv
(
'PATH'
)
:
getenv
(
'PATH'
);
$path
.
=
':'
.
dirname
(
PHP_BINARY
);
$env
=
$process
->
getEnv
();
$env
[
'PATH'
]
=
$path
;
$process
->
setEnv
(
$env
);
return
$process
;
}
return
new
Process
(
$command
);
// @codeCoverageIgnore
}
catch
(
ExceptionInterface
$e
)
{
// @codeCoverageIgnore
throw
new
LogicException
(
$e
->
getMessage
(),
(
int
)
$e
->
getCode
(),
$e
);
$process
=
$this
->
decorated
->
create
(
$command
);
$env
=
$process
->
getEnv
();
if
(
$this
->
isComposerCommand
(
$command
))
{
$env
[
'COMPOSER_HOME'
]
=
$this
->
getComposerHomePath
();
}
// Ensure that the running PHP binary is in the PATH.
$env
[
'PATH'
]
=
$this
->
getEnv
(
'PATH'
)
.
':'
.
dirname
(
PHP_BINARY
);
return
$process
->
setEnv
(
$env
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/Updater.php
+
0
−
33
View file @
70ef2270
...
...
@@ -262,39 +262,6 @@ class Updater {
$this
->
stager
->
stage
(
$command
,
$this
->
getStageDirectory
());
}
/**
* Returns the value of an environment variable.
*
* @param string $variable
* The name of the variable.
*
* @return mixed
* The value of the variable.
*/
private
function
getEnv
(
string
$variable
)
{
if
(
function_exists
(
'apache_getenv'
))
{
return
apache_getenv
(
$variable
);
}
return
getenv
(
$variable
);
}
/**
* Sets the value of an environment variable.
*
* @param string $variable
* The name of the variable.
* @param mixed $value
* The value to set.
*/
private
function
setEnv
(
string
$variable
,
$value
):
void
{
if
(
function_exists
(
'apache_setenv'
))
{
apache_setenv
(
$variable
,
$value
);
}
else
{
putenv
(
"
$variable
=
$value
"
);
}
}
/**
* Initializes an active update and returns its ID.
*
...
...
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