Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
digit-joinup-reference
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review 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
ec-europa
digit-joinup-reference
Commits
6f8b7778
Commit
6f8b7778
authored
7 months ago
by
Claudiu Cristea
Browse files
Options
Downloads
Patches
Plain Diff
ISAICP-9052L Improve the joinup_core.file_config_read_only service.
parent
4418cad7
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
web/modules/custom/joinup_core/src/FileConfigReadOnly.php
+11
-19
11 additions, 19 deletions
web/modules/custom/joinup_core/src/FileConfigReadOnly.php
with
11 additions
and
19 deletions
web/modules/custom/joinup_core/src/FileConfigReadOnly.php
+
11
−
19
View file @
6f8b7778
...
...
@@ -4,6 +4,7 @@
namespace
Drupal\joinup_core
;
use
Drupal\Core\File\FileExists
;
use
Drupal\Core\File\FileSystemInterface
;
/**
...
...
@@ -11,12 +12,7 @@
*/
class
FileConfigReadOnly
implements
ConfigReadOnlyInterface
{
/**
* File name of the disabled config readonly.
*
* @var string
*/
protected
const
string
FILE_NAME
=
'disable-config-readonly'
;
protected
const
string
FILE
=
'private://killswitch/disable-config-readonly'
;
public
function
__construct
(
protected
FileSystemInterface
$fileSystem
)
{}
...
...
@@ -24,7 +20,11 @@ public function __construct(protected FileSystemInterface $fileSystem) {}
* {@inheritdoc}
*/
public
function
isReadOnlyEnabled
():
bool
{
return
!
file_exists
(
$this
->
pathToReadOnlyFile
());
$file
=
$this
->
fileSystem
->
realpath
(
static
::
FILE
);
if
(
$file
&&
file_exists
(
$file
))
{
return
TRUE
;
}
return
FALSE
;
}
/**
...
...
@@ -32,7 +32,8 @@ public function isReadOnlyEnabled(): bool {
*/
public
function
enableReadOnly
():
void
{
if
(
!
$this
->
isReadOnlyEnabled
())
{
$this
->
fileSystem
->
unlink
(
$this
->
pathToReadOnlyFile
());
$file
=
$this
->
fileSystem
->
realpath
(
static
::
FILE
);
$this
->
fileSystem
->
unlink
(
$file
);
}
}
...
...
@@ -40,17 +41,8 @@ public function enableReadOnly(): void {
* {@inheritdoc}
*/
public
function
disableReadOnly
():
void
{
touch
(
$this
->
pathToReadOnlyFile
());
}
/**
* Returns the file path to disable the config readonly flag.
*
* @return string
* The file path
*/
protected
function
pathToReadOnlyFile
():
string
{
return
DRUPAL_ROOT
.
'/../'
.
self
::
FILE_NAME
;
$file
=
$this
->
fileSystem
->
realpath
(
static
::
FILE
);
$this
->
fileSystem
->
saveData
(
''
,
$file
,
FileExists
::
Replace
);
}
}
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