You are here

protected function FeaturesAssignmentMethodBase::assignPackageByConfigTypes in Features 8.3

Same name and namespace in other branches
  1. 8.4 src/FeaturesAssignmentMethodBase.php \Drupal\features\FeaturesAssignmentMethodBase::assignPackageByConfigTypes()

Assigns configuration of the types specified in a setting to a package.

Parameters

string $machine_name: Machine name of the package.

bool $force: (optional) If TRUE, assign config regardless of restrictions such as it being already assigned to a package.

3 calls to FeaturesAssignmentMethodBase::assignPackageByConfigTypes()
FeaturesAssignmentCoreType::assignPackages in src/Plugin/FeaturesAssignment/FeaturesAssignmentCoreType.php
Performs package assignment.
FeaturesAssignmentProfile::assignPackages in src/Plugin/FeaturesAssignment/FeaturesAssignmentProfile.php
Performs package assignment.
FeaturesAssignmentSiteType::assignPackages in src/Plugin/FeaturesAssignment/FeaturesAssignmentSiteType.php
Performs package assignment.

File

src/FeaturesAssignmentMethodBase.php, line 78

Class

FeaturesAssignmentMethodBase
Base class for package assignment methods.

Namespace

Drupal\features

Code

protected function assignPackageByConfigTypes($machine_name, $force = FALSE) {
  $current_bundle = $this->assigner
    ->getBundle();
  $settings = $current_bundle
    ->getAssignmentSettings($this
    ->getPluginId());
  $types = $settings['types']['config'];
  $config_collection = $this->featuresManager
    ->getConfigCollection();
  foreach ($config_collection as $item_name => $item) {

    // Don't assign configuration that's provided by an extension.
    if (in_array($item
      ->getType(), $types) && !$item
      ->isProviderExcluded()) {
      try {
        $this->featuresManager
          ->assignConfigPackage($machine_name, [
          $item_name,
        ]);
      } catch (\Exception $exception) {
        \Drupal::logger('features')
          ->error($exception
          ->getMessage());
      }
    }
  }
}