updated contrib modules : pathauto, token, entity_api, search_api, redirect, features

This commit is contained in:
2018-09-12 15:05:44 +02:00
parent b8e8cc8cee
commit a4746432c7
281 changed files with 4839 additions and 2453 deletions
@@ -9,6 +9,7 @@ use Drupal\Core\Config\StorageInterface;
use Drupal\features\Exception\DomainException;
use Drupal\features\Exception\InvalidArgumentException;
use Drupal\features\FeaturesAssignerInterface;
use Drupal\features\FeaturesBundleInterface;
use Drupal\features\FeaturesGeneratorInterface;
use Drupal\features\FeaturesManagerInterface;
use Drupal\features\Plugin\FeaturesGeneration\FeaturesGenerationWrite;
@@ -246,7 +247,7 @@ class FeaturesCommands extends DrushCommands {
public function listPackages($package_name = NULL, $options = self::OPTIONS_LIST) {
$assigner = $this->featuresOptions($options);
$current_bundle = $assigner->getBundle();
$namespace = $current_bundle->isDefault() ? '' : $current_bundle->getMachineName();
$namespace = $current_bundle->isDefault() ? FeaturesBundleInterface::DEFAULT_BUNDLE : $current_bundle->getMachineName();
$manager = $this->manager;
$packages = $manager->getPackages();
@@ -312,7 +313,7 @@ class FeaturesCommands extends DrushCommands {
public function importAll($options = self::OPTIONS_IMPORT_ALL) {
$assigner = $this->featuresOptions($options);
$currentBundle = $assigner->getBundle();
$namespace = $currentBundle->isDefault() ? '' : $currentBundle->getMachineName();
$namespace = $currentBundle->isDefault() ? FeaturesBundleInterface::DEFAULT_BUNDLE : $currentBundle->getMachineName();
$manager = $this->manager;
$packages = $manager->getPackages();
@@ -69,7 +69,7 @@ class FeaturesController implements ContainerInjectionInterface {
throw new AccessDeniedHttpException();
}
$request = new Request(array('file' => $uri));
$request = new Request(['file' => $uri]);
return $this->fileDownloadController->download($request, 'temporary');
}
}
@@ -193,7 +193,7 @@ class FeaturesBundle extends ConfigEntityBase implements FeaturesBundleInterface
* {@inheritdoc}
*/
public function getEnabledAssignments() {
$list = array();
$list = [];
foreach ($this->assignments as $method_id => $method) {
if ($method['enabled']) {
$list[$method_id] = $method_id;
@@ -221,7 +221,7 @@ class FeaturesBundle extends ConfigEntityBase implements FeaturesBundleInterface
* {@inheritdoc}
*/
public function getAssignmentWeights() {
$list = array();
$list = [];
foreach ($this->assignments as $method_id => $method) {
$list[$method_id] = $method['weight'];
}
@@ -275,7 +275,7 @@ class FeaturesBundle extends ConfigEntityBase implements FeaturesBundleInterface
}
}
else {
$list = array();
$list = [];
foreach (array_keys($this->assignments) as $method_id) {
$list[$method_id] = $this->getAssignmentSettings($method_id);
}
@@ -113,7 +113,7 @@ class FeaturesAssigner implements FeaturesAssignerInterface {
* {@inheritdoc}
*/
public function reset() {
$this->methods = array();
$this->methods = [];
$this->featuresManager->reset();
}
@@ -181,7 +181,7 @@ class FeaturesAssigner implements FeaturesAssignerInterface {
*/
protected function getAssignmentMethodInstance($method_id) {
if (!isset($this->methods[$method_id])) {
$instance = $this->assignerManager->createInstance($method_id, array());
$instance = $this->assignerManager->createInstance($method_id, []);
$instance->setFeaturesManager($this->featuresManager);
$instance->setAssigner($this);
$instance->setEntityTypeManager($this->entityTypeManager);
@@ -261,7 +261,7 @@ class FeaturesAssigner implements FeaturesAssignerInterface {
*/
public function getBundleList() {
if (empty($this->bundles)) {
$this->bundles = array();
$this->bundles = [];
foreach ($this->entityTypeManager->getStorage('features_bundle')->loadMultiple() as $machine_name => $bundle) {
$this->bundles[$machine_name] = $bundle;
}
@@ -279,7 +279,7 @@ class FeaturesAssigner implements FeaturesAssignerInterface {
return $bundle;
}
}
$machine_name = strtolower(str_replace(array(' ', '-'), '_', $name));
$machine_name = strtolower(str_replace([' ', '-'], '_', $name));
if (isset($bundles[$machine_name])) {
return $bundles[$machine_name];
}
@@ -311,7 +311,7 @@ class FeaturesAssigner implements FeaturesAssignerInterface {
$bundle->setDescription($description);
}
else {
$bundle->setDescription(t('Auto-generated bundle from package @name', array('@name' => $name)));
$bundle->setDescription(t('Auto-generated bundle from package @name', ['@name' => $name]));
}
$bundle->setIsProfile($is_profile);
if (isset($profile_name)) {
@@ -374,7 +374,7 @@ class FeaturesAssigner implements FeaturesAssignerInterface {
*/
public function getBundleOptions() {
$list = $this->getBundleList();
$result = array();
$result = [];
foreach ($list as $machine_name => $bundle) {
$result[$machine_name] = $bundle->getName();
}
@@ -17,9 +17,9 @@ class FeaturesConfigDependencyManager extends ConfigDependencyManager{
* {@inheritdoc}
*/
public function getDependentEntities($type, $name) {
$dependent_entities = array();
$dependent_entities = [];
$entities_to_check = array();
$entities_to_check = [];
if ($type == 'config') {
$entities_to_check[] = $name;
}
@@ -42,7 +42,7 @@ class FeaturesConfigDependencyManager extends ConfigDependencyManager{
// always after field storages. This is because field storages need to be
// created before a field.
$this->sorted_graph = $this->getGraph();
uasort($this->sorted_graph, array($this, 'sortGraph'));
uasort($this->sorted_graph, [$this, 'sortGraph']);
}
return array_replace(array_intersect_key($this->sorted_graph, $dependencies), $dependencies);
}
@@ -75,7 +75,7 @@ class FeaturesConfigInstaller extends ConfigInstaller {
$features_config = array_keys($this->featuresManager->listExistingConfig());
// Map array so we can use isset instead of in_array for faster access.
$features_config = array_combine($features_config, $features_config);
$existing_configuration = array();
$existing_configuration = [];
// Gather information about all the supported collections.
$collection_info = $this->configManager->getConfigCollectionInfo();
@@ -0,0 +1,24 @@
<?php
namespace Drupal\features;
/**
* Wraps FeaturesInstallStorage to support multiple configuration
* directories.
*/
class FeaturesExtensionStoragesByDirectory extends FeaturesExtensionStorages implements FeaturesExtensionStoragesByDirectoryInterface {
/**
* {@inheritdoc}
*/
public function listAllByDirectory($prefix = '') {
if (!isset($this->configurationLists[$prefix])) {
$this->configurationLists[$prefix] = [];
foreach ($this->extensionStorages as $directory => $extension_storage) {
$this->configurationLists[$prefix] += array_fill_keys($extension_storage->listAll($prefix), $directory);
}
}
return $this->configurationLists[$prefix];
}
}
@@ -0,0 +1,26 @@
<?php
namespace Drupal\features;
/**
* Defines an extended interface for extension storages.
*/
interface FeaturesExtensionStoragesByDirectoryInterface extends FeaturesExtensionStoragesInterface {
/**
* Returns a list of all configuration available from extensions.
*
* This method was made public late in the 8.x-3.x cycle and so is not
* included in the interface.
*
* @param string $prefix
* (optional) The prefix to search for. If omitted, all configuration object
* names that exist are returned.
*
* @return array
* An array with configuration item names as keys and configuration
* directories as values.
*/
public function listAllByDirectory($prefix = '');
}
@@ -65,7 +65,7 @@ abstract class FeaturesGenerationMethodBase implements FeaturesGenerationMethodI
/**
* {@inheritdoc}
*/
public function prepare(array &$packages = array(), FeaturesBundleInterface $bundle = NULL) {
public function prepare(array &$packages = [], FeaturesBundleInterface $bundle = NULL) {
// If no packages were specified, get all packages.
if (empty($packages)) {
$packages = $this->featuresManager->getPackages();
@@ -37,7 +37,7 @@ interface FeaturesGenerationMethodInterface {
* @return array
* An array of packages data.
*/
public function prepare(array &$packages = array(), FeaturesBundleInterface $bundle = NULL);
public function prepare(array &$packages = [], FeaturesBundleInterface $bundle = NULL);
/**
* Performs package generation.
@@ -56,7 +56,7 @@ interface FeaturesGenerationMethodInterface {
* - 'message': a message about the result of the operation.
* - 'variables': an array of substitutions to be used in the message.
*/
public function generate(array $packages = array(), FeaturesBundleInterface $bundle = NULL);
public function generate(array $packages = [], FeaturesBundleInterface $bundle = NULL);
/**
* Responds to the submission of
@@ -69,13 +69,13 @@ class FeaturesGenerator implements FeaturesGeneratorInterface {
* {@inheritdoc}
*/
public function reset() {
$this->methods = array();
$this->methods = [];
}
/**
* {@inheritdoc}
*/
public function applyGenerationMethod($method_id, array $packages = array(), FeaturesBundleInterface $bundle = NULL) {
public function applyGenerationMethod($method_id, array $packages = [], FeaturesBundleInterface $bundle = NULL) {
$method = $this->getGenerationMethodInstance($method_id);
$method->prepare($packages, $bundle);
return $method->generate($packages, $bundle);
@@ -107,7 +107,7 @@ class FeaturesGenerator implements FeaturesGeneratorInterface {
*/
protected function getGenerationMethodInstance($method_id) {
if (!isset($this->methods[$method_id])) {
$instance = $this->generatorManager->createInstance($method_id, array());
$instance = $this->generatorManager->createInstance($method_id, []);
$instance->setFeaturesManager($this->featuresManager);
$instance->setAssigner($this->assigner);
$this->methods[$method_id] = $instance;
@@ -118,7 +118,7 @@ class FeaturesGenerator implements FeaturesGeneratorInterface {
/**
* {@inheritdoc}
*/
public function generatePackages($method_id, FeaturesBundleInterface $bundle, array $package_names = array()) {
public function generatePackages($method_id, FeaturesBundleInterface $bundle, array $package_names = []) {
$this->featuresManager->setPackageBundleNames($bundle, $package_names);
return $this->generate($method_id, $bundle, $package_names);
}
@@ -144,7 +144,7 @@ class FeaturesGenerator implements FeaturesGeneratorInterface {
* - 'message': a message about the result of the operation.
* - 'variables': an array of substitutions to be used in the message.
*/
protected function generate($method_id, FeaturesBundleInterface $bundle, array $package_names = array()) {
protected function generate($method_id, FeaturesBundleInterface $bundle, array $package_names = []) {
$packages = $this->featuresManager->getPackages();
// Filter out the packages that weren't requested.
@@ -71,7 +71,7 @@ interface FeaturesGeneratorInterface {
* - 'message': a message about the result of the operation.
* - 'variables': an array of substitutions to be used in the message.
*/
public function applyGenerationMethod($method_id, array $packages = array(), FeaturesBundleInterface $bundle = NULL);
public function applyGenerationMethod($method_id, array $packages = [], FeaturesBundleInterface $bundle = NULL);
/**
* Responds to the submission of
@@ -98,6 +98,6 @@ interface FeaturesGeneratorInterface {
* Array of names of packages to be generated. If none are specified, all
* available packages will be added.
*/
public function generatePackages($method_id, FeaturesBundleInterface $bundle, array $package_names = array());
public function generatePackages($method_id, FeaturesBundleInterface $bundle, array $package_names = []);
}
@@ -66,7 +66,7 @@ class FeaturesInstallStorage extends ExtensionInstallStorage {
*/
public function getAllFolders() {
if (!isset($this->folders)) {
$this->folders = array();
$this->folders = [];
$this->folders += $this->getCoreNames();
$install_profile = Settings::get('install_profile');
@@ -117,8 +117,8 @@ class FeaturesInstallStorage extends ExtensionInstallStorage {
// CHANGED START: Put Features modules first in list returned.
// to allow features to override config provided by other extensions.
$featuresManager = \Drupal::service('features.manager');
$features_list = array();
$module_list = array();
$features_list = [];
$module_list = [];
foreach (array_keys($module_list_scan) as $module) {
if ($featuresManager->isFeatureModule($module_list_scan[$module])) {
$features_list[$module] = $module_list_scan[$module];
@@ -150,7 +150,7 @@ class FeaturesInstallStorage extends ExtensionInstallStorage {
$profile_list = $listing->scan('profile');
}
if (isset($profile_list[$profile])) {
$profile_folders = $this->getComponentNames(array($profile_list[$profile]));
$profile_folders = $this->getComponentNames([$profile_list[$profile]]);
$this->folders = $profile_folders + $this->folders;
}
}
@@ -39,7 +39,7 @@ class FeaturesManager implements FeaturesManagerInterface {
/**
* The extension storages.
*
* @var \Drupal\features\FeaturesExtensionStoragesInterface
* @var \Drupal\features\FeaturesExtensionStoragesByDirectoryInterface
*/
protected $extensionStorages;
@@ -148,7 +148,7 @@ class FeaturesManager implements FeaturesManagerInterface {
$this->configFactory = $config_factory;
$this->configReverter = $config_reverter;
$this->settings = $config_factory->getEditable('features.settings');
$this->extensionStorages = new FeaturesExtensionStorages($this->configStorage);
$this->extensionStorages = new FeaturesExtensionStoragesByDirectory($this->configStorage);
$this->extensionStorages->addStorage(InstallStorage::CONFIG_INSTALL_DIRECTORY);
$this->extensionStorages->addStorage(InstallStorage::CONFIG_OPTIONAL_DIRECTORY);
$this->packages = [];
@@ -196,10 +196,10 @@ class FeaturesManager implements FeaturesManagerInterface {
* {@inheritdoc}
*/
public function getConfigType($fullname) {
$result = array(
$result = [
'type' => '',
'name_short' => '',
);
];
$prefix = FeaturesManagerInterface::SYSTEM_SIMPLE_CONFIG . '.';
if (strpos($fullname, $prefix) !== FALSE) {
$result['type'] = FeaturesManagerInterface::SYSTEM_SIMPLE_CONFIG;
@@ -320,7 +320,7 @@ class FeaturesManager implements FeaturesManagerInterface {
* {@inheritdoc}
*/
public function filterPackages(array $packages, $namespace = '', $only_exported = FALSE) {
$result = array();
$result = [];
/** @var \Drupal\features\Package $package */
foreach ($packages as $key => $package) {
// A package matches the namespace if:
@@ -417,7 +417,7 @@ class FeaturesManager implements FeaturesManagerInterface {
/**
* {@inheritdoc}
*/
public function listPackageDirectories(array $machine_names = array(), FeaturesBundleInterface $bundle = NULL) {
public function listPackageDirectories(array $machine_names = [], FeaturesBundleInterface $bundle = NULL) {
if (empty($machine_names)) {
$machine_names = array_keys($this->getPackages());
}
@@ -438,7 +438,7 @@ class FeaturesManager implements FeaturesManagerInterface {
return in_array($module->getName(), $machine_names);
});
$directories = array();
$directories = [];
foreach ($modules as $module) {
$directories[$module->getName()] = $module->getPath();
}
@@ -546,7 +546,7 @@ class FeaturesManager implements FeaturesManagerInterface {
* @param array $module_list
* @return array $dependencies
*/
protected function getConfigDependency(ConfigurationItem $config, $module_list = array()) {
protected function getConfigDependency(ConfigurationItem $config, $module_list = []) {
$dependencies = [];
$type = $config->getType();
@@ -737,7 +737,7 @@ class FeaturesManager implements FeaturesManagerInterface {
$packages = $this->getPackages();
}
else {
$packages = array($package);
$packages = [$package];
}
$module_list = $this->moduleHandler->getModuleList();
$config_collection = $this->getConfigCollection();
@@ -940,7 +940,7 @@ class FeaturesManager implements FeaturesManagerInterface {
}
if ($package->getConfig()) {
foreach (array('excluded', 'required') as $constraint) {
foreach (['excluded', 'required'] as $constraint) {
if (!empty($package->{'get' . $constraint}())) {
$features_info[$constraint] = $package->{'get' . $constraint}();
}
@@ -957,7 +957,7 @@ class FeaturesManager implements FeaturesManagerInterface {
// The name and description need to be cast as strings from the
// TranslatableMarkup objects returned by t() to avoid raising an
// InvalidDataTypeException on Yaml serialization.
foreach (array('name', 'description') as $key) {
foreach (['name', 'description'] as $key) {
$info[$key] = (string) $info[$key];
}
@@ -1008,7 +1008,7 @@ class FeaturesManager implements FeaturesManagerInterface {
/**
* {@inheritdoc}
*/
public function mergeInfoArray(array $info1, array $info2, array $keys = array()) {
public function mergeInfoArray(array $info1, array $info2, array $keys = []) {
// If keys were specified, use only those.
if (!empty($keys)) {
$info2 = array_intersect_key($info2, array_fill_keys($keys, NULL));
@@ -1061,7 +1061,7 @@ class FeaturesManager implements FeaturesManagerInterface {
* {@inheritdoc}
*/
public function listExistingConfig($installed = FALSE, FeaturesBundleInterface $bundle = NULL) {
$config = array();
$config = [];
$existing = $this->getFeaturesModules($bundle, $installed);
foreach ($existing as $extension) {
// Keys are configuration item names and values are providing extension
@@ -1150,6 +1150,7 @@ class FeaturesManager implements FeaturesManagerInterface {
$dependency_manager = $this->getFeaturesConfigDependencyManager();
// List configuration provided by installed features.
$existing_config = $this->listExistingConfig(NULL);
$existing_config_by_directory = $this->extensionStorages->listAllByDirectory();
foreach (array_keys($config_types) as $config_type) {
$config = $this->listConfigByType($config_type);
foreach ($config as $item_name => $label) {
@@ -1162,7 +1163,7 @@ class FeaturesManager implements FeaturesManagerInterface {
'type' => $config_type,
'dependents' => array_keys($dependency_manager->getDependentEntities('config', $name)),
// Default to the install directory.
'subdirectory' => InstallStorage::CONFIG_INSTALL_DIRECTORY,
'subdirectory' => isset($existing_config_by_directory[$name]) ? $existing_config_by_directory[$name] : InstallStorage::CONFIG_INSTALL_DIRECTORY,
'package' => '',
'providerExcluded' => NULL,
'provider' => isset($existing_config[$name]) ? $existing_config[$name] : NULL,
@@ -1211,7 +1212,7 @@ class FeaturesManager implements FeaturesManagerInterface {
$path = dirname($extension_path);
}
return array($full_name, $path);
return [$full_name, $path];
}
/**
@@ -1221,11 +1222,11 @@ class FeaturesManager implements FeaturesManagerInterface {
/** @var \Drupal\config_update\ConfigDiffInterface $config_diff */
$config_diff = \Drupal::service('config_update.config_diff');
$different = array();
$different = [];
foreach ($feature->getConfig() as $name) {
$active = $this->configStorage->read($name);
$extension = $this->extensionStorages->read($name);
$extension = !empty($extension) ? $extension : array();
$extension = !empty($extension) ? $extension : [];
if (($include_new || !empty($extension)) && !$config_diff->same($extension, $active)) {
$different[] = $name;
}
@@ -1241,7 +1242,7 @@ class FeaturesManager implements FeaturesManagerInterface {
* {@inheritdoc}
*/
public function detectNew(Package $feature) {
$result = array();
$result = [];
foreach ($feature->getConfig() as $name) {
$extension = $this->extensionStorages->read($name);
if (empty($extension)) {
@@ -1256,7 +1257,7 @@ class FeaturesManager implements FeaturesManagerInterface {
*/
public function detectMissing(Package $feature) {
$config = $this->getConfigCollection();
$result = array();
$result = [];
foreach ($feature->getConfigOrig() as $name) {
if (!isset($config[$name])) {
$result[] = $name;
@@ -1269,8 +1270,8 @@ class FeaturesManager implements FeaturesManagerInterface {
* {@inheritdoc}
*/
public function reorderMissing(array $missing) {
$list = array();
$result = array();
$list = [];
$result = [];
foreach ($missing as $full_name) {
$this->addConfigList($full_name, $list);
}
@@ -328,7 +328,7 @@ interface FeaturesManagerInterface {
* @return array
* Array of package directories keyed by package machine name.
*/
public function listPackageDirectories(array $machine_names = array(), FeaturesBundleInterface $bundle = NULL);
public function listPackageDirectories(array $machine_names = [], FeaturesBundleInterface $bundle = NULL);
/**
* Assigns a set of configuration items to a given package or profile.
@@ -414,7 +414,7 @@ interface FeaturesManagerInterface {
*
* @fixme Should this be moved to the package object or a related helper?
*/
public function mergeInfoArray(array $info1, array $info2, array $keys = array());
public function mergeInfoArray(array $info1, array $info2, array $keys = []);
/**
* Lists the types of configuration available on the site.
@@ -429,7 +429,7 @@ class Package {
$this->setBundle($features_info['bundle']);
}
$this->setRequired(isset($features_info['required']) ? $features_info['required'] : false);
$this->setExcluded(isset($features_info['excluded']) ? $features_info['excluded'] : array());
$this->setExcluded(isset($features_info['excluded']) ? $features_info['excluded'] : []);
return $this;
}
@@ -2,7 +2,7 @@
namespace Drupal\features\Plugin\FeaturesAssignment;
use Drupal\component\Utility\Unicode;
use Drupal\Component\Utility\Unicode;
use Drupal\features\FeaturesAssignmentMethodBase;
/**
@@ -37,7 +37,7 @@ class FeaturesAssignmentBaseType extends FeaturesAssignmentMethodBase {
foreach ($config_collection as $item_name => $item) {
if (in_array($item->getType(), $config_base_types)) {
if (is_null($this->featuresManager->findPackage($item->getShortName())) && !$item->getPackage()) {
$description = $this->t('Provides @label @type and related configuration.', array('@label' => $item->getLabel(), '@type' => Unicode::strtolower($config_types[$item->getType()])));
$description = $this->t('Provides @label @type and related configuration.', ['@label' => $item->getLabel(), '@type' => Unicode::strtolower($config_types[$item->getType()])]);
if (isset($item->getData()['description'])) {
$description .= ' ' . $item->getData()['description'];
}
@@ -59,7 +59,7 @@ class FeaturesAssignmentBaseType extends FeaturesAssignmentMethodBase {
foreach ($content_base_types as $entity_type_id) {
if (!isset($packages[$entity_type_id]) && isset($entity_types[$entity_type_id])) {
$label = $entity_types[$entity_type_id]->getLabel();
$description = $this->t('Provide @label related configuration.', array('@label' => $label));
$description = $this->t('Provide @label related configuration.', ['@label' => $label]);
$this->featuresManager->initPackage($entity_type_id, $label, $description, 'module', $current_bundle);
}
}
@@ -71,7 +71,7 @@ class FeaturesAssignmentProfile extends FeaturesAssignmentMethodBase {
// Only read in from the Standard profile if this profile doesn't already
// exist.
$package_directories = $this->featuresManager->listPackageDirectories(array(), $current_bundle);
$package_directories = $this->featuresManager->listPackageDirectories([], $current_bundle);
if (!isset($package_directories[$profile_name])) {
$standard_directory = 'core/profiles/standard';
// Conditionally add files from the 'standard' install profile.
@@ -128,7 +128,7 @@ class FeaturesGenerationArchive extends FeaturesGenerationMethodBase implements
/**
* {@inheritdoc}
*/
public function generate(array $packages = array(), FeaturesBundleInterface $bundle = NULL) {
public function generate(array $packages = [], FeaturesBundleInterface $bundle = NULL) {
// If no packages were specified, get all packages.
if (empty($packages)) {
@@ -101,7 +101,7 @@ class FeaturesGenerationWrite extends FeaturesGenerationMethodBase implements Co
/**
* {@inheritdoc}
*/
public function generate(array $packages = array(), FeaturesBundleInterface $bundle = NULL) {
public function generate(array $packages = [], FeaturesBundleInterface $bundle = NULL) {
// If no packages were specified, get all packages.
if (empty($packages)) {
$packages = $this->featuresManager->getPackages();