本文整理匯總了PHP中Drupal\Core\Config\ConfigImporter::logError方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConfigImporter::logError方法的具體用法?PHP ConfigImporter::logError怎麽用?PHP ConfigImporter::logError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Config\ConfigImporter
的用法示例。
在下文中一共展示了ConfigImporter::logError方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validateDependencies
/**
* Validates configuration being imported does not have unmet dependencies.
*
* @param \Drupal\Core\Config\ConfigImporter $config_importer
* The configuration importer.
*/
protected function validateDependencies(ConfigImporter $config_importer)
{
$core_extension = $config_importer->getStorageComparer()->getSourceStorage()->read('core.extension');
$existing_dependencies = ['config' => $config_importer->getStorageComparer()->getSourceStorage()->listAll(), 'module' => array_keys($core_extension['module']), 'theme' => array_keys($core_extension['theme'])];
$theme_data = $this->getThemeData();
$module_data = $this->getModuleData();
// Validate the dependencies of all the configuration. We have to validate
// the entire tree because existing configuration might depend on
// configuration that is being deleted.
foreach ($config_importer->getStorageComparer()->getSourceStorage()->listAll() as $name) {
// Ensure that the config owner is installed. This checks all
// configuration including configuration entities.
list($owner, ) = explode('.', $name, 2);
if ($owner !== 'core') {
$message = FALSE;
if (!isset($core_extension['module'][$owner]) && isset($module_data[$owner])) {
$message = $this->t('Configuration %name depends on the %owner module that will not be installed after import.', array('%name' => $name, '%owner' => $module_data[$owner]->info['name']));
} elseif (!isset($core_extension['theme'][$owner]) && isset($theme_data[$owner])) {
$message = $this->t('Configuration %name depends on the %owner theme that will not be installed after import.', array('%name' => $name, '%owner' => $theme_data[$owner]->info['name']));
} elseif (!isset($core_extension['module'][$owner]) && !isset($core_extension['theme'][$owner])) {
$message = $this->t('Configuration %name depends on the %owner extension that will not be installed after import.', array('%name' => $name, '%owner' => $owner));
}
if ($message) {
$config_importer->logError($message);
continue;
}
}
$data = $config_importer->getStorageComparer()->getSourceStorage()->read($name);
// Configuration entities have dependencies on modules, themes, and other
// configuration entities that we can validate. Their content dependencies
// are not validated since we assume that they are soft dependencies.
// Configuration entities can be identified by having 'dependencies' and
// 'uuid' keys.
if (isset($data['dependencies']) && isset($data['uuid'])) {
$dependencies_to_check = array_intersect_key($data['dependencies'], array_flip(['module', 'theme', 'config']));
foreach ($dependencies_to_check as $type => $dependencies) {
$diffs = array_diff($dependencies, $existing_dependencies[$type]);
if (!empty($diffs)) {
$message = FALSE;
switch ($type) {
case 'module':
$message = $this->formatPlural(count($diffs), 'Configuration %name depends on the %module module that will not be installed after import.', 'Configuration %name depends on modules (%module) that will not be installed after import.', array('%name' => $name, '%module' => implode(', ', $this->getNames($diffs, $module_data))));
break;
case 'theme':
$message = $this->formatPlural(count($diffs), 'Configuration %name depends on the %theme theme that will not be installed after import.', 'Configuration %name depends on themes (%theme) that will not be installed after import.', array('%name' => $name, '%theme' => implode(', ', $this->getNames($diffs, $theme_data))));
break;
case 'config':
$message = $this->formatPlural(count($diffs), 'Configuration %name depends on the %config configuration that will not exist after import.', 'Configuration %name depends on configuration (%config) that will not exist after import.', array('%name' => $name, '%config' => implode(', ', $diffs)));
break;
}
if ($message) {
$config_importer->logError($message);
}
}
}
}
}
}