/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $definitions = $this->aliasTypeManager->getDefinitions(); $config = $this->config('pathauto.pattern'); foreach ($definitions as $id => $definition) { /** @var \Drupal\pathauto\AliasTypeInterface $alias_type */ $alias_type = $this->aliasTypeManager->createInstance($id, $config->get('patterns.' . $id)); $form[$id] = $alias_type->buildConfigurationForm([], $form_state); } return parent::buildForm($form, $form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { if ($form_state->getValue(['delete', 'all_aliases'])) { db_delete('url_alias')->execute(); drupal_set_message($this->t('All of your path aliases have been deleted.')); } foreach (array_keys(array_filter($form_state->getValue(['delete', 'plugins']))) as $id) { /** @var \Drupal\pathauto\AliasTypeInterface $alias_type */ $alias_type = $this->aliasTypeManager->createInstance($id); db_delete('url_alias')->condition('source', db_like($alias_type->getSourcePrefix()) . '%', 'LIKE')->execute(); drupal_set_message(t('All of your %label path aliases have been deleted.', array('%label' => $alias_type->getLabel()))); } $form_state->setRedirect('pathauto.bulk.update.form'); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $storage_helper = \Drupal::service('pathauto.alias_storage_helper'); if ($form_state->getValue(['delete', 'all_aliases'])) { $storage_helper->deleteAll(); drupal_set_message($this->t('All of your path aliases have been deleted.')); } foreach (array_keys(array_filter($form_state->getValue(['delete', 'plugins']))) as $id) { $alias_type = $this->aliasTypeManager->createInstance($id); $storage_helper->deleteBySourcePrefix((string) $alias_type->getSourcePrefix()); drupal_set_message($this->t('All of your %label path aliases have been deleted.', array('%label' => $alias_type->getLabel()))); } $form_state->setRedirect('pathauto.admin.delete'); }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form = array(); $form['#update_callbacks'] = array(); $form['update'] = array('#type' => 'checkboxes', '#title' => $this->t('Select the types of un-aliased paths for which to generate URL aliases'), '#options' => array(), '#default_value' => array()); $definitions = $this->aliasTypeManager->getVisibleDefinitions(); foreach ($definitions as $id => $definition) { $alias_type = $this->aliasTypeManager->createInstance($id); if ($alias_type instanceof AliasTypeBatchUpdateInterface) { $form['update']['#options'][$id] = $alias_type->getLabel(); } } $form['actions']['#type'] = 'actions'; $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Update')); return $form; }