/** * Tests the attribute route title callback. */ function testAttributeTitle() { /** @var \Drupal\linkit\AttributeInterface $plugin */ $plugin = $this->container->get('plugin.manager.linkit.attribute')->createInstance('configurable_dummy_attribute'); $this->linkitProfile->addAttribute($plugin->getConfiguration()); $this->linkitProfile->save(); $this->drupalGet(Url::fromRoute('linkit.attribute.edit', [ 'linkit_profile' => $this->linkitProfile->id(), 'plugin_instance_id' => $plugin->getPluginId(), ])); $this->assertText('Edit ' . $plugin->getLabel() . ' attribute'); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $form_state->cleanValues(); /** @var \Drupal\linkit\AttributeInterface $plugin */ $plugin = $this->manager->createInstance($form_state->getValue('plugin')); $plugin_id = $this->linkitProfile->addAttribute($plugin->getConfiguration()); $this->linkitProfile->save(); $this->logger('linkit')->notice('Added %label attribute to the @profile profile.', [ '%label' => $this->linkitProfile->getAttribute($plugin_id)->getLabel(), '@profile' => $this->linkitProfile->label(), ]); $is_configurable = $plugin instanceof ConfigurableAttributeInterface; if ($is_configurable) { $form_state->setRedirect('linkit.attribute.edit', [ 'linkit_profile' => $this->linkitProfile->id(), 'plugin_instance_id' => $plugin_id, ]); } else { drupal_set_message($this->t('Added %label attribute.', ['%label' => $plugin->getLabel()])); $form_state->setRedirect('linkit.attributes', [ 'linkit_profile' => $this->linkitProfile->id(), ]); } }