/**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $settings = array(
      'types' => array_filter($form_state->getValue('types')),
    );
    $this->currentBundle->setAssignmentSettings(self::METHOD_ID, $settings)->save();
    $this->setRedirect($form_state);

    drupal_set_message($this->t('Package assignment configuration saved.'));
  }
Ejemplo n.º 2
0
 /**
  * @covers Drupal\features\Plugin\FeaturesAssignment\FeaturesAssignmentOptionalType
  */
 public function testAssignOptionalType()
 {
     $method_id = 'optional';
     // Enable the method.
     $this->enableAssignmentMethod($method_id);
     $settings = ['types' => ['config' => ['image_style']]];
     $this->bundle->setAssignmentSettings($method_id, $settings);
     // Add some configuration.
     $this->addConfigurationItem('node.type.article', [], ['type' => 'node_type']);
     $this->addConfigurationItem('image.style.test', [], ['type' => 'image_style']);
     $this->featuresManager->initPackage(self::PACKAGE_NAME, 'My test package');
     $this->assigner->applyAssignmentMethod($method_id);
     $packages = $this->featuresManager->getPackages();
     $this->assertNotEmpty($packages[self::PACKAGE_NAME], 'Expected package not created.');
     $config = $this->featuresManager->getConfigCollection();
     $this->assertNotEmpty($config['node.type.article'], 'Expected config not created.');
     $this->assertNotEmpty($config['image.style.test'], 'Expected config not created.');
     $this->assertNull($config['node.type.article']->getSubdirectory(), 'Expected package subdirectory not set to default.');
     $this->assertEquals($config['image.style.test']->getSubdirectory(), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, 'Expected package subdirectory not set to optional.');
 }