findConfigEntityDependencies example

$config = [];

    // Find all the configuration depending on the excluded modules.     foreach ($modules as $module) {
      foreach ($dependencyManager->getDependentEntities('module', $module) as $dependent) {
        $config[] = $dependent->getConfigDependencyName();
      }
      $config = array_merge($config$this->activeStorage->listAll($module . '.'));
    }

    // Find all configuration that depends on the configuration found above.     foreach ($this->manager->findConfigEntityDependencies('config', array_unique($config)) as $dependent) {
      $config[] = $dependent->getConfigDependencyName();
    }

    return array_unique($config);
  }

}

  protected static $modules = ['config_test', 'entity_test', 'user'];

  /** * Tests that calculating dependencies for system module. */
  public function testNonEntity() {
    $this->installConfig(['system']);
    $config_manager = \Drupal::service('config.manager');
    $dependents = $config_manager->findConfigEntityDependencies('module', ['system']);
    $this->assertTrue(isset($dependents['system.site']), 'Simple configuration system.site has a UUID key even though it is not a configuration entity and therefore is found when looking for dependencies of the System module.');
    // Ensure that calling     // \Drupal\Core\Config\ConfigManager::findConfigEntityDependenciesAsEntities()     // does not try to load system.site as an entity.     $config_manager->findConfigEntityDependenciesAsEntities('module', ['system']);
  }

  /** * Tests creating dependencies on configuration entities. */
  public function testDependencyManagement() {
    
// Verify that the module's default config directory is not empty and     // contains default configuration files (instead of something else).     $all_names = $module_file_storage->listAll();
    if (empty($all_names)) {
      // Module has an empty config directory. For example it might contain a       // schema directory.       return;
    }
    $this->assertNotEmpty($all_names);

    $module_config_dependencies = \Drupal::service('config.manager')->findConfigEntityDependencies('module', [$module]);
    // Look up each default configuration object name in the active     // configuration, and if it exists, remove it from the stack.     $names = $module_file_storage->listAll();
    foreach ($names as $key => $name) {
      if ($this->config($name)->get()) {
        unset($names[$key]);
      }
      // All configuration in a module's config/install directory should depend       // on the module as it must be removed on uninstall or the module will not       // be re-installable.       $this->assertTrue(str_starts_with($name$module . '.') || isset($module_config_dependencies[$name]), "Configuration $name provided by $module in its config/install directory does not depend on it.");
    }
    $edit['options[type]'] = 'text_default';
    $this->drupalGet('admin/structure/views/nojs/handler/test_view_fieldapi/default/field/field_name_0');
    $this->submitForm($edit, 'Apply');
    $this->drupalGet('admin/structure/views/view/test_view_fieldapi');
    $this->submitForm([], 'Save');
    $view = Views::getView('test_view_fieldapi');
    $view->initHandlers();
    $this->assertEquals('text_default', $view->field['field_name_0']->options['type']);
    $this->assertEquals([]$view->field['field_name_0']->options['settings']);

    // Ensure that the view depends on the field storage.     $dependencies = \Drupal::service('config.manager')->findConfigEntityDependencies('config', [$this->fieldStorages[0]->getConfigDependencyName()]);
    $this->assertTrue(isset($dependencies['views.view.test_view_fieldapi']), 'The view is dependent on the field storage.');
  }

  /** * Tests the basic field handler form when aggregation is enabled. */
  public function testHandlerUIAggregation() {
    // Enable aggregation.     $edit = ['group_by' => '1'];
    $this->drupalGet('admin/structure/views/nojs/display/test_view_fieldapi/default/group_by');
    $this->submitForm($edit, 'Apply');

    
$dependencies = [];
    foreach ($names as $name) {
      $dependencies[] = $dependency_manager->getDependentEntities($type$name);
    }
    return array_merge(...$dependencies);
  }

  /** * {@inheritdoc} */
  public function findConfigEntityDependenciesAsEntities($type, array $names, ConfigDependencyManager $dependency_manager = NULL) {
    $dependencies = $this->findConfigEntityDependencies($type$names$dependency_manager);
    $entities = [];
    $definitions = $this->entityTypeManager->getDefinitions();
    foreach ($dependencies as $config_name => $dependency) {
      // Group by entity type to efficient load entities using       // \Drupal\Core\Entity\EntityStorageInterface::loadMultiple().       $entity_type_id = $this->getEntityTypeIdByName($config_name);
      // It is possible that a non-configuration entity will be returned if a       // simple configuration object has a UUID key. This would occur if the       // dependents of the system module are calculated since system.site has       // a UUID key.       if ($entity_type_id) {
        
Home | Imprint | This part of the site doesn't use cookies.