t('Are you sure you want to delete the @plugin attribute from the %profile profile?', ['%profile' => $this->linkitProfile->label(), '@plugin' => $this->linkitAttribute->getLabel()]); } /** * {@inheritdoc} */ public function getCancelUrl() { return Url::fromRoute('linkit.attributes', [ 'linkit_profile' => $this->linkitProfile->id(), ]); } /** * {@inheritdoc} */ public function getFormId() { return 'linkit_attribute_delete_form'; } /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, ProfileInterface $linkit_profile = NULL, $plugin_instance_id = NULL) { $this->linkitProfile = $linkit_profile; if (!$this->linkitProfile->getAttributes()->has($plugin_instance_id)) { throw new NotFoundHttpException(); } $this->linkitAttribute = $this->linkitProfile->getAttribute($plugin_instance_id); return parent::buildForm($form, $form_state); } /** * {@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(), ]); } }