Problem/Motivation

We need to import components in a flexible way and assure that all dependencies are met correctly. The current process import all at the same time, not allowing partial component importing or checking for dependencies.

Proposed resolution

Create a set of methods that analyze component files and generate an ordered and prioritized list of components and then import them.

Remaining tasks

This is a raw work in progress, and the idea is to discuss the best way to achieve what we need. Right now there is a lot stuff to change in order to provide this feature completely. Only to mention:

load() (for storage class)
In the future we will need to import independent files, perhaps, from random paths. So we have to provide a way to override root path for configuration files.

checkDependencies()
Right now is only checking for dependencies in staging and files. We have to cover actual active store objects in order to provide features like importing independent files directly to activestore.

User interface changes

None

API changes

2 new method for the Configuration class.

getPriorizatedDependencies()
Recursively check a component and its dependencies to build an ordered array of components to be imported related to a single component.

checkNewConfigurations()
Use getPriorizatedDependencies() to generate a more general array that cover all components for an import process. Right now is using a static variable to assure that we do not include any component more than 1 time.

Major change to importAllNewConfigurations() now called importConfigurations()

No it receives an array of components in order to process and import them.

Comments

gdrupal’s picture

Status: Active » Needs review
gdrupal’s picture

StatusFileSize
new11.85 KB

Work in progress.

dagmar’s picture

Status: Needs review » Needs work
+++ b/lib/Drupal/configuration/Config/Configuration.phpundefined
@@ -110,58 +102,108 @@ class Configuration {
-    $look_for = '/' . static::$component . '\..*' . $ext . '$/';
+    $look_for = '/\A' . static::$component . '\..*' . $ext . '$/';

What does this \A means?

+++ b/lib/Drupal/configuration/Config/Configuration.phpundefined
@@ -110,58 +102,108 @@ class Configuration {
+      $filename = $file->name;

I've seen issues witht the use of $file->name, it's a problem with the namespaces.

+++ b/lib/Drupal/configuration/Config/MenuConfiguration.phpundefined
@@ -17,14 +17,14 @@ class MenuConfiguration extends Configuration {
-                ->fields('c', array('data'))
-                ->condition('component', self::$component)
-                ->execute()
-                ->fetchCol();
-    
+            ->fields('c', array('data'))
+            ->condition('component', self::$component)
+            ->execute()
+            ->fetchCol();

This is not neccesary to change. Maybe a problem with your IDE.

There a are a lot of changes (removed empty lines and alignment issues) that make this patch harder to review, please try to ajust your ide settings to reflect only the important changes.

gdrupal’s picture

What does this \A means?

For taking files that only begins with a string if not, you get any file with "menu" string when looking "menu" for example you will get "view.menu-data" or "menulink.main-menu.218.Home".

I've seen issues witht the use of $file->name, it's a problem with the namespaces.

I did not know about that We can use the array instead, NP!

About Other changes of coding "look", I have my ide configured to follow drupal coding standar so when I use auto format to remove tailing spaces and so, it fixes indent too and other stuff.

gdrupal’s picture

Status: Needs work » Needs review
StatusFileSize
new7.31 KB

New patch with fixes..

dagmar’s picture

Status: Needs review » Needs work
+++ b/lib/Drupal/configuration/Config/Configuration.phpundefined
@@ -110,58 +102,107 @@ class Configuration {
+    if (empty($this->dependencies)) {
+      $id = $this->getUniqueId();

$id could be defined outside the if. It is defined twice in the if and in the else.

+++ b/lib/Drupal/configuration/Config/Configuration.phpundefined
@@ -110,58 +102,107 @@ class Configuration {
+        if (!in_array($dependency, $component_ordered_stack)) {

Question. What about use the key of component_ordered_stack instead of add a new item using $component_ordered_stack? This is because we could have duplicated values in the stack if we are not using the $id as the key of the array. Also I think is faster than use in_array().

Finally, there are several empty lines removed at the begining of the patch. I preffer to have an empty line between each class property.

gdrupal’s picture

StatusFileSize
new5.96 KB

New patch with more fixes ;)

dagmar’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated for matching 2nd patch