/** * 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(); $plugin_data = (new FormState())->setValues($form_state->getValues()); $this->linkitMatcher->submitConfigurationForm($form, $plugin_data); $this->linkitProfile->save(); drupal_set_message($this->t('Saved %label configuration.', array('%label' => $this->linkitMatcher->getLabel()))); $this->logger('linkit')->notice('The matcher %label has been updated in the @profile profile.', [ '%label' => $this->linkitMatcher->getLabel(), '@profile' => $this->linkitProfile->label(), ]); $form_state->setRedirect('linkit.matchers', [ 'linkit_profile' => $this->linkitProfile->id(), ]); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $form_state->cleanValues(); /** @var \Drupal\linkit\MatcherInterface $plugin */ $plugin = $this->manager->createInstance($form_state->getValue('plugin')); $plugin_uuid = $this->linkitProfile->addMatcher($plugin->getConfiguration()); $this->linkitProfile->save(); $this->logger('linkit')->notice('Added %label matcher to the @profile profile.', [ '%label' => $this->linkitProfile->getMatcher($plugin_uuid)->getLabel(), '@profile' => $this->linkitProfile->label(), ]); $is_configurable = $plugin instanceof ConfigurableMatcherInterface; if ($is_configurable) { $form_state->setRedirect('linkit.matcher.edit', [ 'linkit_profile' => $this->linkitProfile->id(), 'plugin_instance_id' => $plugin_uuid, ]); } else { drupal_set_message($this->t('Added %label matcher.', ['%label' => $plugin->getLabel()])); $form_state->setRedirect('linkit.matchers', [ 'linkit_profile' => $this->linkitProfile->id(), ]); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { if ($this->linkitProfile->getAttributes()->has($this->linkitAttribute->getPluginId())) { $this->linkitProfile->removeAttribute($this->linkitAttribute->getPluginId()); $this->linkitProfile->save(); drupal_set_message($this->t('The attribute %label has been deleted.', ['%label' => $this->linkitAttribute->getLabel()])); $this->logger('linkit')->notice('The attribute %label has been deleted in the @profile profile.', [ '%label' => $this->linkitAttribute->getLabel(), '@profile' => $this->linkitProfile->label(), ]); } $form_state->setRedirect('linkit.attributes', [ 'linkit_profile' => $this->linkitProfile->id(), ]); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { foreach ($form_state->getValue('plugins') as $id => $plugin_data) { if ($this->linkitProfile->getMatchers()->has($id)) { $this->linkitProfile->getMatcher($id)->setWeight($plugin_data['weight']); } } $this->linkitProfile->save(); }