Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drupal Config
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
plugin
Drupal Config
Commits
d852b05a
Commit
d852b05a
authored
3 months ago
by
GitLab CI
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' into 'main'
Merging develop into main See merge request
!9
parents
c388c49b
b35d00eb
No related branches found
No related tags found
1 merge request
!9
Merging develop into main
Pipeline
#1384006
passed
3 months ago
Stage: release
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/FlushCacheCommand.php
+5
-1
5 additions, 1 deletion
src/FlushCacheCommand.php
src/Plugin.php
+30
-9
30 additions, 9 deletions
src/Plugin.php
with
35 additions
and
10 deletions
src/FlushCacheCommand.php
+
5
−
1
View file @
d852b05a
...
...
@@ -28,7 +28,11 @@ class FlushCacheCommand extends BaseCommand {
*/
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
):
int
{
$count
=
0
;
foreach
(
glob
(
Plugin
::
getCacheDir
(
$this
->
requireComposer
())
.
'*'
)
as
$file
)
{
$cache_dir
=
Plugin
::
getCacheDir
(
$this
->
requireComposer
());
if
(
$cache_dir
===
NULL
)
{
return
1
;
}
foreach
(
glob
(
$cache_dir
.
'*'
)
as
$file
)
{
if
(
is_file
(
$file
))
{
unlink
(
$file
);
$count
++
;
...
...
This diff is collapsed.
Click to expand it.
src/Plugin.php
+
30
−
9
View file @
d852b05a
...
...
@@ -5,12 +5,14 @@ namespace LakeDrops\DrupalConfig;
use
Composer\Composer
;
use
Composer\Installers\Installer
;
use
Composer\IO\IOInterface
;
use
Composer\Plugin\Capability\CommandProvider
as
ComposerCommandProvider
;
use
Composer\Plugin\Capable
;
use
Composer\Plugin\PluginInterface
;
/**
* Composer plugin for handling drupal scaffold.
*/
class
Plugin
implements
PluginInterface
{
class
Plugin
implements
PluginInterface
,
Capable
{
/**
* The installer.
...
...
@@ -19,17 +21,30 @@ class Plugin implements PluginInterface {
*/
private
Installer
$installer
;
/**
* {@inheritdoc}
*/
public
function
getCapabilities
():
array
{
return
[
ComposerCommandProvider
::
class
=>
CommandProvider
::
class
,
];
}
/**
* Determines and prepares the cache directory.
*
* @param \Composer\Composer $composer
* The composer instance.
*
* @return string
* @return string
|null
* The cache directory.
*/
public
static
function
getCacheDir
(
Composer
$composer
):
string
{
$cacheDir
=
$composer
->
getConfig
()
->
get
(
'cache-dir'
)
.
'/lakedrops-drupal-config/'
;
public
static
function
getCacheDir
(
Composer
$composer
):
?string
{
$composerCacheDir
=
$composer
->
getConfig
()
->
get
(
'cache-dir'
);
if
(
$composerCacheDir
===
'/dev/null'
)
{
return
NULL
;
}
$cacheDir
=
$composerCacheDir
.
'/lakedrops-drupal-config/'
;
if
(
!
file_exists
(
$cacheDir
))
{
mkdir
(
$cacheDir
);
}
...
...
@@ -141,14 +156,20 @@ class Plugin implements PluginInterface {
*/
protected
function
readJson
(
string
$type
,
string
$filename
,
IOInterface
$io
,
Composer
$composer
):
array
{
try
{
$cache_file
=
self
::
getCacheDir
(
$composer
)
.
md5
(
$filename
);
if
(
!
file_exists
(
$cache_file
)
||
(
filemtime
(
$cache_file
)
+
86400
<
time
()))
{
$io
->
write
(
'<info>Gathering fresh '
.
$type
.
' from '
.
$filename
.
'.</info>'
);
$cache_dir
=
self
::
getCacheDir
(
$composer
);
if
(
$cache_dir
===
NULL
)
{
$content
=
file_get_contents
(
$filename
);
file_put_contents
(
$cache_file
,
$content
);
}
else
{
$content
=
file_get_contents
(
$cache_file
);
$cache_file
=
$cache_dir
.
md5
(
$filename
);
if
(
!
file_exists
(
$cache_file
)
||
(
filemtime
(
$cache_file
)
+
86400
<
time
()))
{
$io
->
write
(
'<info>Gathering fresh '
.
$type
.
' from '
.
$filename
.
'.</info>'
);
$content
=
file_get_contents
(
$filename
);
file_put_contents
(
$cache_file
,
$content
);
}
else
{
$content
=
file_get_contents
(
$cache_file
);
}
}
$data
=
json_decode
(
$content
,
TRUE
,
512
,
JSON_THROW_ON_ERROR
);
$error
=
json_last_error
();
...
...
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