Skip to content
Snippets Groups Projects
Commit a18e2ede authored by Robin van Sloten's avatar Robin van Sloten Committed by Joris Vercammen
Browse files

Issue #3040947 by borisson_, Neograph734: This alias is already in use for...

Issue #3040947 by borisson_, Neograph734: This alias is already in use for another facet defined on the same source
parent c944e1d1
No related merge requests found
......@@ -636,14 +636,6 @@ class FacetForm extends EntityForm {
elseif (preg_match('/[^a-zA-Z0-9_~\.\-]/', $url_alias)) {
$form_state->setErrorByName('url_alias', $this->t('The URL alias contains characters that are not allowed.'));
}
$already_enabled_facets_on_same_source = \Drupal::service('facets.manager')->getFacetsByFacetSourceId($facet->getFacetSourceId());
/** @var \Drupal\facets\FacetInterface $other */
foreach ($already_enabled_facets_on_same_source as $other) {
if ($other->getUrlAlias() === $url_alias && $other->id() !== $facet->id()) {
$form_state->setErrorByName('url_alias', $this->t('This alias is already in use for another facet defined on the same source.'));
}
}
}
/**
......@@ -717,7 +709,17 @@ class FacetForm extends EntityForm {
$facet->set('show_title', $form_state->getValue(['facet_settings', 'show_title'], FALSE));
$facet->save();
\Drupal::messenger()->addMessage($this->t('Facet %name has been updated.', ['%name' => $facet->getName()]));
$already_enabled_facets_on_same_source = \Drupal::service('facets.manager')
->getFacetsByFacetSourceId($facet->getFacetSourceId());
/** @var \Drupal\facets\FacetInterface $other */
foreach ($already_enabled_facets_on_same_source as $other) {
if ($other->getUrlAlias() === $facet->getUrlAlias() && $other->id() !== $facet->id()) {
$this->messenger()->addWarning($this->t('This alias is already in use for another facet defined on the same source.'));
}
}
$this->messenger()->addMessage($this->t('Facet %name has been updated.', ['%name' => $facet->getName()]));
}
/**
......
......@@ -205,7 +205,7 @@ class UrlIntegrationTest extends FacetsTestBase {
}
/**
* Tests that creating a facet with a duplicate url alias is forbidden.
* Tests that creating a facet with a duplicate url alias emits a warning.
*/
public function testCreatingDuplicateUrlAlias() {
$this->createFacet('Owl', 'owl');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment