当前位置: 首页>>代码示例>>PHP>>正文


PHP ConfigImporter::logError方法代码示例

本文整理汇总了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);
                     }
                 }
             }
         }
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:64,代码来源:ConfigImportSubscriber.php


注:本文中的Drupal\Core\Config\ConfigImporter::logError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。