/** * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { $form['label'] = [ '#type' => 'textfield', '#title' => $this->t('Profile Name'), '#default_value' => $this->entity->label(), '#description' => $this->t('The human-readable name of this profile. This name must be unique.'), '#required' => TRUE, '#size' => 30, ]; $form['id'] = [ '#type' => 'machine_name', '#default_value' => $this->entity->id(), '#machine_name' => [ 'exists' => ['\Drupal\linkit\Entity\Profile', 'load'] ], '#disabled' => !$this->entity->isNew(), ]; $form['description'] = [ '#type' => 'textarea', '#title' => $this->t('Description'), '#default_value' => $this->entity->getDescription(), '#description' => $this->t('The text will be displayed on the <em>profile collection</em> page.'), ]; $form['additional_settings'] = array( '#type' => 'vertical_tabs', '#weight' => 99, ); return parent::form($form, $form_state); }
/** * Tests the profile route title callback. */ function testProfileTitle() { $this->drupalGet(Url::fromRoute('entity.linkit_profile.edit_form', [ 'linkit_profile' => $this->linkitProfile->id(), ])); $this->assertText('Edit ' . $this->linkitProfile->label() . ' profile'); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->linkitProfile->removeMatcher($this->linkitMatcher); drupal_set_message($this->t('The matcher %label has been deleted.', ['%label' => $this->linkitMatcher->getLabel()])); $this->logger('linkit')->notice('The matcher %label has been deleted 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(); $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(), ]); }
/** * Route title callback. * * @param \Drupal\linkit\ProfileInterface $linkit_profile * The profile. * * @return string * The profile label as a render array. */ public function profileTitle(ProfileInterface $linkit_profile) { return $this->t('Edit %label profile', array('%label' => $linkit_profile->label())); }