Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
dfd537fe
Commit
dfd537fe
authored
Oct 28, 2013
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2095489
by tayzlor, beejeebus: Separate out module install config code from import code.
parent
05fbc52f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
121 deletions
+32
-121
core/includes/config.inc
core/includes/config.inc
+31
-18
core/lib/Drupal/Core/Config/ConfigInstaller.php
core/lib/Drupal/Core/Config/ConfigInstaller.php
+0
-33
core/lib/Drupal/Core/Config/ExtensionInstallStorage.php
core/lib/Drupal/Core/Config/ExtensionInstallStorage.php
+1
-28
core/lib/Drupal/Core/Config/ExtensionInstallStorageComparer.php
...ib/Drupal/Core/Config/ExtensionInstallStorageComparer.php
+0
-38
core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php
...ules/config/lib/Drupal/config/Tests/ConfigInstallTest.php
+0
-4
No files found.
core/includes/config.inc
View file @
dfd537fe
...
...
@@ -3,11 +3,10 @@
use
Drupal\Component\Utility\Unicode
;
use
Drupal\Core\Config\Config
;
use
Drupal\Core\Config\ConfigException
;
use
Drupal\Core\Config\ConfigInstaller
;
use
Drupal\Core\Config\ExtensionInstallStorage
;
use
Drupal\Core\Config\Context\FreeConfigContext
;
use
Drupal\Core\Config\FileStorage
;
use
Drupal\Core\Config\StorageInterface
;
use
Drupal\Core\Config\ExtensionInstallStorageComparer
;
use
Symfony\Component\Yaml\Dumper
;
/**
...
...
@@ -37,8 +36,6 @@
* The name of the module or theme to install default configuration for.
*
* @see \Drupal\Core\Config\ExtensionInstallStorage
* @see \Drupal\Core\Config\ExtensionInstallStorageComparer
* @see \Drupal\Core\Config\ConfigInstaller
*/
function
config_install_default_config
(
$type
,
$name
)
{
// Get all default configuration owned by this extension.
...
...
@@ -66,20 +63,36 @@ function ($value) use ($name) {
$config_to_install
=
array_merge
(
$config_to_install
,
$other_module_config
);
}
if
(
!
empty
(
$config_to_install
))
{
$storage_comparer
=
new
ExtensionInstallStorageComparer
(
$source_storage
,
\
Drupal
::
service
(
'config.storage'
));
$storage_comparer
->
setSourceNames
(
$config_to_install
);
// Only import new config. Changed config is from previous enables and
// should not be overwritten.
$storage_comparer
->
addChangelistCreate
();
$installer
=
new
ConfigInstaller
(
$storage_comparer
,
\
Drupal
::
service
(
'event_dispatcher'
),
\
Drupal
::
service
(
'config.factory'
),
\
Drupal
::
entityManager
(),
\
Drupal
::
lock
(),
\
Drupal
::
service
(
'uuid'
)
);
$installer
->
import
();
$entity_manager
=
Drupal
::
service
(
'entity.manager'
);
$config_factory
=
Drupal
::
service
(
'config.factory'
);
$context
=
new
FreeConfigContext
(
Drupal
::
service
(
'event_dispatcher'
),
Drupal
::
service
(
'uuid'
));
$target_storage
=
Drupal
::
service
(
'config.storage'
);
$config_factory
->
enterContext
(
$context
);
foreach
(
$config_to_install
as
$name
)
{
// Only import new config.
if
(
$target_storage
->
exists
(
$name
))
{
continue
;
}
$new_config
=
new
Config
(
$name
,
$target_storage
,
$context
);
$data
=
$source_storage
->
read
(
$name
);
if
(
$data
!==
FALSE
)
{
$new_config
->
setData
(
$data
);
}
if
(
$entity_type
=
config_get_entity_type_by_name
(
$name
))
{
$entity_manager
->
getStorageController
(
$entity_type
)
->
create
(
$new_config
->
get
())
->
save
();
}
else
{
$new_config
->
save
();
}
// Reset static cache on the config factory.
$config_factory
->
reset
(
$name
);
}
$config_factory
->
leaveContext
();
}
}
...
...
core/lib/Drupal/Core/Config/ConfigInstaller.php
deleted
100644 → 0
View file @
05fbc52f
<?php
/**
* @file
* Contains \Drupal\Core\Config\ConfigInstaller.
*/
namespace
Drupal\Core\Config
;
/**
* Defines a configuration installer.
*
* A config installer imports the changes into the configuration system during
* module installs.
*
* The ConfigInstaller has a identifier which is used to construct event names.
* The events fired during an import are:
* - 'config.installer.validate': Events listening can throw a
* \Drupal\Core\Config\ConfigImporterException to prevent an import from
* occurring.
* @see \Drupal\Core\EventSubscriber\ConfigImportSubscriber
* - 'config.installer.import': Events listening can react to a successful import.
*
* @see \Drupal\Core\Config\ConfigImporter
*/
class
ConfigInstaller
extends
ConfigImporter
{
/**
* The name used to identify events and the lock.
*/
const
ID
=
'config.installer'
;
}
core/lib/Drupal/Core/Config/ExtensionInstallStorage.php
View file @
dfd537fe
...
...
@@ -30,32 +30,5 @@ protected function getAllFolders() {
}
return
$this
->
folders
;
}
/**
* {@inheritdoc}
*
* @throws \Drupal\Core\Config\StorageException
*/
public
function
write
(
$name
,
array
$data
)
{
throw
new
StorageException
(
'Write operation is not allowed for config extension install storage.'
);
}
/**
* {@inheritdoc}
*
* @throws \Drupal\Core\Config\StorageException
*/
public
function
delete
(
$name
)
{
throw
new
StorageException
(
'Delete operation is not allowed for config extension install storage.'
);
}
/**
* {@inheritdoc}
*
* @throws \Drupal\Core\Config\StorageException
*/
public
function
rename
(
$name
,
$new_name
)
{
throw
new
StorageException
(
'Rename operation is not allowed for config extension install storage.'
);
}
}
core/lib/Drupal/Core/Config/ExtensionInstallStorageComparer.php
deleted
100644 → 0
View file @
05fbc52f
<?php
/**
* @file
* Contains \Drupal\Core\Config\ExtensionInstallStorageComparer.
*/
namespace
Drupal\Core\Config
;
/**
* Defines a config storage comparer.
*/
class
ExtensionInstallStorageComparer
extends
StorageComparer
{
/**
* Sets the configuration names in the source storage.
*
* @param array $source_names
* List of all the configuration names in the source storage.
*/
public
function
setSourceNames
(
array
$source_names
)
{
$this
->
sourceNames
=
$source_names
;
return
$this
;
}
/**
* Gets all the configuration names in the source storage.
*
* @return array
* List of all the configuration names in the source storage.
*
* @see self::setSourceNames()
*/
protected
function
getSourceNames
()
{
return
$this
->
sourceNames
;
}
}
core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php
View file @
dfd537fe
...
...
@@ -52,10 +52,6 @@ function testModuleInstallation() {
$config
=
\
Drupal
::
config
(
$default_configuration_entity
);
$this
->
assertIdentical
(
$config
->
isNew
(),
FALSE
);
// Verify that configuration import callback was invoked for the dynamic
// configuration entity.
$this
->
assertTrue
(
$GLOBALS
[
'hook_config_import'
]);
// Verify that config_test API hooks were invoked for the dynamic default
// configuration entity.
$this
->
assertFalse
(
isset
(
$GLOBALS
[
'hook_config_test'
][
'load'
]));
...
...
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