Commit 135ca1c0 authored by Dries's avatar Dries

Issue #2294177 by alexpott: Allow Drupal\Core to provide [config] entity types.

parent 1a53cd14
......@@ -107,6 +107,8 @@ public function installDefaultConfig($type, $name) {
$extension_config = $this->configFactory->get('core.extension');
$enabled_extensions = array_keys((array) $extension_config->get('module'));
$enabled_extensions += array_keys((array) $extension_config->get('theme'));
// Core can provide configuration.
$enabled_extensions[] = 'core';
foreach ($collection_info->getCollectionNames(TRUE) as $collection) {
$config_to_install = $this->listDefaultConfigCollection($collection, $type, $name, $enabled_extensions);
......
......@@ -358,7 +358,7 @@ protected function addDependency($type, $name) {
// explicitly declare the dependency. An explicit dependency on Core, which
// provides some plugins, is also not needed.
// @see \Drupal\Core\Config\Entity\ConfigEntityDependency::hasDependency()
if ($type == 'module' && ($name == $this->getEntityType()->getProvider() || $name == 'Core')) {
if ($type == 'module' && ($name == $this->getEntityType()->getProvider() || $name == 'core')) {
return $this;
}
......
......@@ -234,7 +234,7 @@ protected function findDefinitions() {
if (is_object($plugin_definition) && !($plugin_definition = (array) $plugin_definition)) {
continue;
}
if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array('Core', 'Component')) && !$this->moduleHandler->moduleExists($plugin_definition['provider'])) {
if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array('core', 'component')) && !$this->moduleHandler->moduleExists($plugin_definition['provider'])) {
unset($definitions[$plugin_id]);
}
}
......
......@@ -9,6 +9,7 @@
use Drupal\Component\Annotation\AnnotationInterface;
use Drupal\Component\Annotation\Plugin\Discovery\AnnotatedClassDiscovery as ComponentAnnotatedClassDiscovery;
use Drupal\Component\Utility\Unicode;
/**
* Defines a discovery mechanism to find annotated plugins in PSR-0 namespaces.
......@@ -105,7 +106,7 @@ protected function getProviderFromNamespace($namespace) {
preg_match('|^Drupal\\\\(?<provider>[\w]+)\\\\|', $namespace, $matches);
if (isset($matches['provider'])) {
return $matches['provider'];
return Unicode::strtolower($matches['provider']);
}
return NULL;
......
......@@ -150,7 +150,7 @@ protected function findDefinitions() {
// If this plugin was provided by a module that does not exist, remove the
// plugin definition.
foreach ($definitions as $plugin_id => $plugin_definition) {
if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array('Core', 'Component')) && (!$this->moduleHandler->moduleExists($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array_keys($this->themeHandler->listInfo())))) {
if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array('core', 'component')) && (!$this->moduleHandler->moduleExists($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array_keys($this->themeHandler->listInfo())))) {
unset($definitions[$plugin_id]);
}
}
......
......@@ -114,7 +114,7 @@ protected static function initializeSandbox(array &$context, ConfigImporter $con
*/
public static function getFieldsToPurge(array $extensions, array $deletes) {
$providers = array_keys($extensions['module']);
$providers[] = 'Core';
$providers[] = 'core';
$fields_to_delete = array();
// Gather fields that will be deleted during configuration synchronization
......
......@@ -186,11 +186,11 @@ public function testAddDependency() {
$method = new \ReflectionMethod('\Drupal\Core\Config\Entity\ConfigEntityBase', 'addDependency');
$method->setAccessible(TRUE);
$method->invoke($this->entity, 'module', $this->provider);
$method->invoke($this->entity, 'module', 'Core');
$method->invoke($this->entity, 'module', 'core');
$method->invoke($this->entity, 'module', 'node');
$dependencies = $this->entity->get('dependencies');
$this->assertNotContains($this->provider, $dependencies['module']);
$this->assertNotContains('Core', $dependencies['module']);
$this->assertNotContains('core', $dependencies['module']);
$this->assertContains('node', $dependencies['module']);
// Test sorting of dependencies.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment