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
1f9b934a
Commit
1f9b934a
authored
4 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
docker/l3d#58
Move project settings out of composer.json
parent
e06d1abc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Config.php
+34
-0
34 additions, 0 deletions
Config.php
with
34 additions
and
0 deletions
Config.php
+
34
−
0
View file @
1f9b934a
...
...
@@ -12,6 +12,11 @@ final class Config {
private
static
$values
;
/**
* @var string
*/
private
$component
;
/**
* Config constructor.
*
...
...
@@ -20,6 +25,7 @@ final class Config {
* @param \LakeDrops\Component\Dotenv\Dotenv $env
*/
public
function
__construct
(
string
$component
,
array
$default_values
,
Dotenv
$env
)
{
$this
->
component
=
$component
;
$this
->
init
();
$componentValues
=
self
::
$values
[
$component
]
??
[];
self
::
$values
[
$component
]
=
$env
->
replaceEnvironmentVariables
(
NestedArray
::
mergeDeep
(
$default_values
,
$componentValues
));
...
...
@@ -38,4 +44,32 @@ final class Config {
}
}
/**
* @param array $values
* @param array $keys
*
* @return mixed|null
*/
private
function
readValueFromArray
(
$values
,
$keys
)
{
$key
=
array_shift
(
$keys
);
if
(
!
isset
(
$values
[
$key
]))
{
return
NULL
;
}
if
(
empty
(
$keys
))
{
return
$values
[
$key
];
}
return
$this
->
readValueFromArray
(
$values
[
$key
],
$keys
);
}
/**
* @param $path
*
* @return mixed|null
*/
public
function
readValue
(
$path
)
{
$parts
=
explode
(
'/'
,
$path
);
return
$this
->
readValueFromArray
(
self
::
$values
[
$this
->
component
],
$parts
);
}
}
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