class ContentStorageComparer in Content Synchronization 8.2
Same name and namespace in other branches
- 3.0.x src/Content/ContentStorageComparer.php \Drupal\content_sync\Content\ContentStorageComparer
Extends config storage comparer.
Hierarchy
- class \Drupal\Core\Config\StorageComparer implements StorageComparerInterface uses DependencySerializationTrait
- class \Drupal\content_sync\Content\ContentStorageComparer
Expanded class hierarchy of ContentStorageComparer
1 file declares its use of ContentStorageComparer
- ContentSyncCommands.php in src/
Commands/ ContentSyncCommands.php
File
- src/
Content/ ContentStorageComparer.php, line 12
Namespace
Drupal\content_sync\ContentView source
class ContentStorageComparer extends StorageComparer {
/**
* {@inheritdoc}
*/
public function createChangelistbyCollection($collection) {
$this->changelist[$collection] = $this
->getEmptyChangelist();
$this
->getAndSortConfigData($collection);
$this
->addChangelistCreate($collection);
$this
->addChangelistUpdate($collection);
$this
->addChangelistDelete($collection);
// Only collections that support configuration entities can have renames.
if ($collection == StorageInterface::DEFAULT_COLLECTION) {
$this
->addChangelistRename($collection);
}
return $this;
}
/**
* {@inheritdoc}
*/
public function createChangelistbyCollectionAndNames($collection, $names) {
$this->changelist[$collection] = $this
->getEmptyChangelist();
if ($this
->getAndSortContentDataByCollectionAndNames($collection, $names)) {
$this
->addChangelistCreate($collection);
$this
->addChangelistUpdate($collection);
$this
->addChangelistDelete($collection);
// Only collections that support configuration entities can have renames.
if ($collection == StorageInterface::DEFAULT_COLLECTION) {
$this
->addChangelistRename($collection);
}
}
return $this;
}
/**
* Gets and sorts configuration data from the source and target storages.
*/
protected function getAndSortContentDataByCollectionAndNames($collection, $names) {
$names = explode(',', $names);
$target_names = [];
$source_names = [];
foreach ($names as $key => $name) {
$name = $collection . '.' . $name;
$source_storage = $this
->getSourceStorage($collection);
$target_storage = $this
->getTargetStorage($collection);
if ($source_storage
->exists($name) || $target_storage
->exists($name)) {
$target_names = array_merge($target_names, $target_storage
->listAll($name));
$source_names = array_merge($source_names, $source_storage
->listAll($name));
}
}
$target_names = array_filter($target_names);
$source_names = array_filter($source_names);
if (!empty($target_names) || !empty($source_names)) {
// Prime the static caches by reading all the configuration in the source
// and target storages.
$target_data = $target_storage
->readMultiple($target_names);
$source_data = $source_storage
->readMultiple($source_names);
$this->targetNames[$collection] = $target_names;
$this->sourceNames[$collection] = $source_names;
return true;
}
return false;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContentStorageComparer:: |
public | function | ||
ContentStorageComparer:: |
public | function | ||
ContentStorageComparer:: |
protected | function | Gets and sorts configuration data from the source and target storages. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
StorageComparer:: |
protected | property | List of changes to between the source storage and the target storage. | |
StorageComparer:: |
protected | property | A memory cache backend to statically cache source configuration data. | |
StorageComparer:: |
protected | property | Sorted list of all the configuration object names in the source storage. | |
StorageComparer:: |
protected | property | The source storage used to discover configuration changes. | |
StorageComparer:: |
protected | property | The source storages keyed by collection. | |
StorageComparer:: |
protected | property | A memory cache backend to statically cache target configuration data. | |
StorageComparer:: |
protected | property | Sorted list of all the configuration object names in the target storage. | |
StorageComparer:: |
protected | property | The target storage used to write configuration changes. | |
StorageComparer:: |
protected | property | The target storages keyed by collection. | |
StorageComparer:: |
protected | function | Adds changes to the changelist. | |
StorageComparer:: |
protected | function | Creates the create changelist. | |
StorageComparer:: |
protected | function | Creates the delete changelist. | |
StorageComparer:: |
protected | function | Creates the rename changelist. | |
StorageComparer:: |
protected | function | Creates the update changelist. | |
StorageComparer:: |
public | function | ||
StorageComparer:: |
protected | function | Creates a rename name from the old and new names for the object. | |
StorageComparer:: |
public | function |
Extracts old and new configuration names from a configuration change name. Overrides StorageComparerInterface:: |
|
StorageComparer:: |
public | function |
Gets the existing collections from both the target and source storage. Overrides StorageComparerInterface:: |
|
StorageComparer:: |
protected | function | Gets and sorts configuration data from the source and target storages. | |
StorageComparer:: |
public | function |
Gets the list of differences to import. Overrides StorageComparerInterface:: |
|
StorageComparer:: |
public | function |
Gets an empty changelist. Overrides StorageComparerInterface:: |
|
StorageComparer:: |
public | function |
Gets the configuration source storage. Overrides StorageComparerInterface:: |
|
StorageComparer:: |
public | function |
Gets the configuration target storage. Overrides StorageComparerInterface:: |
|
StorageComparer:: |
public | function |
Checks if there are any operations with changes to process. Overrides StorageComparerInterface:: |
|
StorageComparer:: |
public | function |
Moves a rename operation to an update. Overrides StorageComparerInterface:: |
|
StorageComparer:: |
protected | function | Removes the entry from the given operation changelist for the given name. | |
StorageComparer:: |
public | function |
Recalculates the differences. Overrides StorageComparerInterface:: |
|
StorageComparer:: |
public | function |
Validates that the system.site::uuid in the source and target match. Overrides StorageComparerInterface:: |
|
StorageComparer:: |
public | function | Constructs the Configuration storage comparer. |