Skip to content

Commit

Permalink
Merge pull request #1181 from UN-OCHA/release-versions/v1.12.2
Browse files Browse the repository at this point in the history
release versions/v1.12.2
  • Loading branch information
berliner authored Nov 14, 2024
2 parents 3a32087 + 004a466 commit e2dcbee
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 16 deletions.
1 change: 1 addition & 0 deletions config/config_ignore.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mode: simple
ignored_config_entities:
- 'entity_access_password.settings:global_password'
- ghi_blocks.global_settings
- ghi_content.article_settings
- ghi_content.remote_sources
- ghi_embargoed_access.settings
- ghi_hero_image.config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state) {
$disabled_field_text = $this->t('This field is disabled because it is automatically populated from @label.', $t_args);

$overwrite_properties = $migration_definition['destination']['overwrite_properties'] ?? [];
$process_fields = array_keys($migration_definition['process'] ?? []);
$fields = array_unique(array_merge($overwrite_properties, $process_fields));
foreach ($fields as $field_key) {
foreach ($overwrite_properties as $field_key) {
if (!array_key_exists($field_key, $form)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ protected function getLinkFromUri($uri, $label = NULL) {
catch (\InvalidArgumentException $e) {
return NULL;
}
if ($this->isInternalUri($uri)) {
$url->setOption('custom_path', str_replace('internal:', '', $uri));
}
return $this->getLinkFromUrl($url, $label);
}

Expand All @@ -99,8 +102,9 @@ protected function getLinkFromUrl(Url $url, $label = NULL) {
if (!$link) {
return NULL;
}
$is_internal = strpos($url->toUriString(), 'internal:') === 0;
if (!$is_internal && $link->getUrl()->isRouted() && $node = $link->getUrl()->getRouteParameters()['node'] ?? NULL) {
// It's an internal uri if the custom path is set.
$is_internal_uri = $url->getOption('custom_path');
if (!$is_internal_uri && $link->getUrl()->isRouted() && $node = $link->getUrl()->getRouteParameters()['node'] ?? NULL) {
$node = $node instanceof NodeInterface ? $node : \Drupal::entityTypeManager()->getStorage('node')->load($node);
$link->setUrl($node->toUrl());
}
Expand All @@ -124,14 +128,23 @@ protected function getLinkFromUrl(Url $url, $label = NULL) {
$attributes['data-toggle'] = 'tooltip';
}
$attributes['class'] = $classes;

$link->getUrl()->setOption('attributes', $attributes);
if ($is_internal) {
$link->getUrl()->setOption('custom_path', str_replace('internal:', '', $url->toUriString()));
}
return $link;
}

/**
* Check if the given uri should be considered an internal uri.
*
* @param string $uri
* The URI string.
*
* @return bool
* TRUE if the uri string should be considered internal, FALSE otherwise.
*/
private function isInternalUri($uri) {
return str_starts_with($uri, 'internal:');
}

/**
* Transform the given URL from an absolute path to an internal entity uri.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function setUp(): void {
}

/**
* Test getLinkFromUri for external links.
* Test getLinkFromConfiguration for external links.
*/
public function testGetLinkFromUriBasics() {
$class = new CustomLinkTestClass();
Expand All @@ -118,7 +118,7 @@ public function testGetLinkFromUriBasics() {
}

/**
* Test getLinkFromUri for external links.
* Test getLinkFromConfiguration for external links.
*/
public function testGetLinkFromUriExternal() {
$class = new CustomLinkTestClass();
Expand Down Expand Up @@ -160,9 +160,28 @@ public function testGetLinkFromUriExternal() {
}

/**
* Test getLinkFromUri for internal links.
* Test getLinkFromConfiguration for internal links.
*/
public function testGetLinkFromUriInternal() {
$class = new CustomLinkTestClass();
$contexts = [];
$conf = [
'add_link' => TRUE,
'link_type' => 'custom',
'link_custom' => [
'url' => 'internal:/node/' . $this->financialsNode->id(),
],
];
$link = $class->getLinkFromConfiguration($conf, $contexts);
$this->assertInstanceOf(Link::class, $link);
$this->assertEquals('/node/' . $this->financialsNode->id(), $link->getUrl()->getOption('custom_path'));
$this->assertEquals('Go to page', $link->getText());
}

/**
* Test getLinkFromConfiguration for related target links.
*/
public function testGetLinkFromRelatedTarget() {
$class = new CustomLinkTestClass();
$conf = [
'add_link' => TRUE,
Expand Down Expand Up @@ -336,7 +355,8 @@ private function mockEntityUrl(EntityInterface $entity) {
$path = '/node/' . $entity->id();
$url = $this->prophesize(Url::class);
$url->toString()->willReturn($path);
$url->toUriString()->willReturn('internal:' . ltrim($path, '/'));
// $url->toUriString()->willReturn('internal:' . ltrim($path, '/'));
$url->toUriString()->willReturn('route:entity.node.canonical;node=' . $entity->id());
$url->isRouted()->willReturn(TRUE);
$url->getRouteParameters()->willReturn(['node' => $entity]);
$url->access()->willReturn(TRUE);
Expand All @@ -345,6 +365,7 @@ private function mockEntityUrl(EntityInterface $entity) {
$url->getOption('attributes')->willReturn([]);
$url->setOption('attributes', ["class" => ["cd-button", "read-more"]])->willReturn();
$url->setOption('custom_path', ltrim($path, '/'))->willReturn();
$url->getOption('custom_path')->willReturn(ltrim($path, '/'));
return $url;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,29 @@
}

@media (min-width: 504px) {
.gho-achievement-list .field__item {
.gho-achievement-list .field__items.col-3 > .field__item,
.gho-achievement-list .field__items.col-4 > .field__item {
flex: 0 0 calc((100% - 1rem) / 2);
}
}

@media (min-width: 734px) {
.gho-achievement-list .field__item {
.gho-achievement-list .field__items.col-2 > .field__item {
/* Full size col-2 */
flex: 0 0 calc((100% - 2rem) / 2);
}
.gho-achievement-list .field__items.col-4 > .field__items {
flex: 0 0 calc((100% - 2rem) / 3);
}
}

@media (min-width: 960px) {
.gho-achievement-list .field__item {
.gho-achievement-list .field__items.col-3 > .field__item {
/* Full size col-3 */
flex: 0 0 calc((100% - 2rem) / 3);
}
.gho-achievement-list .field__items.col-4 > .field__item {
/* Full size col-4 */
flex: 0 0 calc((100% - 3rem) / 4);
}
}
Expand Down

0 comments on commit e2dcbee

Please sign in to comment.