Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
config_ignore
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
3
Merge Requests
3
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
config_ignore
Commits
2b89ba3e
Commit
2b89ba3e
authored
Feb 12, 2017
by
tlyngej
Committed by
tlyngej
Feb 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2845024
by tlyngej, jrockowitz: Add hook_config_ignore_alter(&$names)
parent
3444442b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
0 deletions
+111
-0
config_ignore.api.php
config_ignore.api.php
+23
-0
src/ConfigImporterIgnore.php
src/ConfigImporterIgnore.php
+1
-0
src/Tests/ConfigIgnoreHookTest.php
src/Tests/ConfigIgnoreHookTest.php
+67
-0
tests/config_ignore_hook_test/config_ignore_hook_test.info.yml
.../config_ignore_hook_test/config_ignore_hook_test.info.yml
+7
-0
tests/config_ignore_hook_test/config_ignore_hook_test.module
tests/config_ignore_hook_test/config_ignore_hook_test.module
+13
-0
No files found.
config_ignore.api.php
0 → 100644
View file @
2b89ba3e
<?php
/**
* @file
* Hooks specific to the Config Ignore module.
*/
/**
* @addtogroup hooks
* @{
*/
/**
* Alter the list of config entities that should be ignored.
*/
function
hook_config_ignore_settings_alter
(
array
&
$settings
)
{
$settings
[]
=
'system.site'
;
$settings
[]
=
'field.*'
;
}
/**
* @} End of "addtogroup hooks".
*/
src/ConfigImporterIgnore.php
View file @
2b89ba3e
...
...
@@ -27,6 +27,7 @@ class ConfigImporterIgnore {
public
static
function
preImport
(
array
&
$context
,
ConfigImporter
$config_importer
)
{
$config_to_ignore
=
[];
$config_ignore_settings
=
\
Drupal
::
config
(
'config_ignore.settings'
)
->
get
(
'ignored_config_entities'
);
\
Drupal
::
moduleHandler
()
->
invokeAll
(
'config_ignore_settings_alter'
,
[
&
$config_ignore_settings
]);
foreach
([
'delete'
,
'create'
,
'rename'
,
'update'
]
as
$op
)
{
// For now, we only support updates.
if
(
$op
==
'update'
)
{
...
...
src/Tests/ConfigIgnoreHookTest.php
0 → 100644
View file @
2b89ba3e
<?php
namespace
Drupal\config_ignore\Tests
;
use
Drupal\simpletest\WebTestBase
;
use
Drupal\Core\Serialization\Yaml
;
/**
* Test hooks that this module implements.
*
* This must be a simpletest test as it does not seem that the PHPUnit
* implementation for Drupal supports batch processing yet.
*
* @package Drupal\config_ignore\Tests
*
* @group config_ignore
*/
class
ConfigIgnoreHookTest
extends
WebTestBase
{
/**
* Modules to enable.
*
* @var array
*/
public
static
$modules
=
[
'config_ignore_hook_test'
];
/**
* The profile to install as a basis for testing.
*
* We need to change it form the standard 'testing' profile as that will not
* print the title on the page, which we use for testing.
*
* @var string
*/
protected
$profile
=
'minimal'
;
/**
* Verify that hook_config_ignore_settings_alter are getting called.
*/
public
function
testSettingsAlterHook
()
{
// Login with a user that has permission to import config.
$this
->
drupalLogin
(
$this
->
drupalCreateUser
([
'import configuration'
]));
// Set the site name to a known value that we later will try and overwrite.
$this
->
config
(
'system.site'
)
->
set
(
'name'
,
'Test import title'
)
->
save
();
// Assemble a change that will try and override the current value.
$config
=
$this
->
config
(
'system.site'
)
->
set
(
'name'
,
'Import has changed title'
);
$edit
=
[
'config_type'
=>
'system.simple'
,
'config_name'
=>
$config
->
getName
(),
'import'
=>
Yaml
::
encode
(
$config
->
get
()),
];
// Submit a new single item config, with the changes.
$this
->
drupalPostForm
(
'admin/config/development/configuration/single/import'
,
$edit
,
t
(
'Import'
));
$this
->
drupalPostForm
(
NULL
,
[],
t
(
'Confirm'
));
// Validate if the title from the imported config was rejected, due to the
// hook implemented in the `config_ignore_hook_test` module.
$this
->
drupalGet
(
'<front>'
);
$this
->
assertText
(
'Test import title'
);
}
}
tests/config_ignore_hook_test/config_ignore_hook_test.info.yml
0 → 100644
View file @
2b89ba3e
name
:
Config Ignore Hook Test
type
:
module
description
:
Module that implements all the hook from Config Ignore for testing purposes
core
:
8.x
package
:
Configuration
dependencies
:
-
config_ignore
tests/config_ignore_hook_test/config_ignore_hook_test.module
0 → 100644
View file @
2b89ba3e
<?php
/**
* @file
* Module that implements all the hook from Config Ignore for testing purposes.
*/
/**
* Implements hook_config_ignore_settings_alter().
*/
function
config_ignore_hook_test_config_ignore_settings_alter
(
array
&
$settings
)
{
$settings
[]
=
'system.site'
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment