You are here

public function FeaturesBundle::setEnabledAssignments in Features 8.3

Same name and namespace in other branches
  1. 8.4 src/Entity/FeaturesBundle.php \Drupal\features\Entity\FeaturesBundle::setEnabledAssignments()

Sets the list of enabled assignment methods.

Parameters

array $assignments: An array of values keyed by assignment method IDs. Non-empty value is enabled.

Overrides FeaturesBundleInterface::setEnabledAssignments

See also

\Drupal\features\FeaturesBundleInterface::getEnabledAssignments()

File

src/Entity/FeaturesBundle.php, line 224

Class

FeaturesBundle
Defines a features bundle.

Namespace

Drupal\features\Entity

Code

public function setEnabledAssignments(array $assignments) {

  // Add any new assignments that we don't yet know about.
  $new_assignments = array_diff($assignments, array_keys($this->assignments));
  foreach ($new_assignments as $method_id) {
    $this->assignments[$method_id] = $this
      ->getAssignmentSettings($method_id);
  }
  foreach ($this->assignments as $method_id => &$method) {
    $method['enabled'] = in_array($method_id, $assignments);
  }
}