Skip to content
Snippets Groups Projects
Verified Commit d291e2a4 authored by Alexandre Dias's avatar Alexandre Dias
Browse files

Merge remote-tracking branch 'origin/develop' into ISAICP-9617

parents 9185d985 f9539813
No related branches found
No related tags found
2 merge requests!215Release 2.3.2,!214ISAICP-9579: Fix SearchWidget: refer own submit callbacks precisely to prevent...
...@@ -102,11 +102,10 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form ...@@ -102,11 +102,10 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form
*/ */
public function submitConfigurationForm(array &$form, FormStateInterface $form_state): void { public function submitConfigurationForm(array &$form, FormStateInterface $form_state): void {
// At this point, all groups are valid and filtered. // At this point, all groups are valid and filtered.
$limit_to_groups = $form_state->getValue('limit_to_groups'); $limit_to_groups = $form_state->getValue('limit_to_groups', '');
$groups = $this->getGroups($limit_to_groups); $groups = $this->getGroups($this->textToArray($limit_to_groups));
$limit_to_groups = array_map(fn (GroupInterface $group): string => $group->id(), $groups); $limit_to_groups = array_map(fn (GroupInterface $group): string => $group->id(), $groups);
$this->setConfig('limit_to_groups', array_unique($limit_to_groups)); $this->setConfig('limit_to_groups', array_values(array_unique($limit_to_groups)));
$form_state->setValue('limit_to_groups', $limit_to_groups);
parent::submitConfigurationForm($form, $form_state); parent::submitConfigurationForm($form, $form_state);
} }
...@@ -115,9 +114,10 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s ...@@ -115,9 +114,10 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s
*/ */
public function summary(): ?MarkupInterface { public function summary(): ?MarkupInterface {
$groups = $this->getGroups(); $groups = $this->getGroups();
if ($groups) {
$groupLabels = array_map(function (GroupInterface $group): string { if (!empty($groups)) {
return $group->get('type')->entity->label() . ': ' . $group->label(); $groupLabels = array_map(function (GroupInterface|null $group): string {
return $group ? $group->get('type')->entity->label() . ': ' . $group->label() : 'Invalid';
}, $groups); }, $groups);
$args = ['@groups' => implode(', ', $groupLabels)]; $args = ['@groups' => implode(', ', $groupLabels)];
if (!$this->isNegated()) { if (!$this->isNegated()) {
...@@ -192,7 +192,8 @@ protected function getGroups(?array $data = NULL): array { ...@@ -192,7 +192,8 @@ protected function getGroups(?array $data = NULL): array {
// Further attempt to recognize the group from the URL if the ID is // Further attempt to recognize the group from the URL if the ID is
// a URI and is internal. // a URI and is internal.
elseif (!UrlHelper::isExternal($id) || UrlHelper::externalIsLocal($id, $this->requestStack->getCurrentRequest()->getSchemeAndHttpHost())) { elseif (!UrlHelper::isExternal($id) || UrlHelper::externalIsLocal($id, $this->requestStack->getCurrentRequest()->getSchemeAndHttpHost())) {
$url = Url::fromUri('internal:' . UrlHelper::parse($id)['path']); $path = trim(UrlHelper::parse($id)['path'], '/');
$url = Url::fromUri("internal:/" . $path);
if ($url->isRouted() && $url->getRouteName() === 'entity.node.canonical') { if ($url->isRouted() && $url->getRouteName() === 'entity.node.canonical') {
$node = $this->entityTypeManager->getStorage('node')->load($url->getRouteParameters()['node']); $node = $this->entityTypeManager->getStorage('node')->load($url->getRouteParameters()['node']);
if ($node instanceof GroupInterface) { if ($node instanceof GroupInterface) {
......
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