Skip to content

Commit

Permalink
hotfix(link-resolver): Update to new interface definition
Browse files Browse the repository at this point in the history
  • Loading branch information
dborsatto committed Nov 8, 2018
1 parent c880db5 commit d9ba2af
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased](https://github.com/contentful/contentful.php/compare/4.0.0...HEAD)

### Fixed

* Second parameter in `LinkResolver::resolveLinkCollection()` was changed from `string $locale = null` to `array $parameters = []`.

## [4.0.0](https://github.com/contentful/contentful.php/tree/4.0.0) (2018-11-08)

**ATTENTION**: This release contains breaking changes. Please take extra care when updating to this version. See [the upgrade guide](UPGRADE-4.0.md) for more.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"require": {
"php": "^7.0",
"contentful/core": "^2.1",
"contentful/core": "^2.1.1",
"contentful/rich-text": "^1.2",
"psr/cache": "^1.0",
"symfony/console": "~2.7|~3.0|~4.0",
Expand Down
4 changes: 3 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,9 @@ public function resolveLink(Link $link, string $locale = \null): ResourceInterfa
*/
public function resolveLinkCollection(array $links, string $locale = \null): array
{
return $this->linkResolver->resolveLinkCollection($links, $locale);
return $this->linkResolver->resolveLinkCollection($links, [
'locale' => (string) $locale,
]);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/LinkResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ public function resolveLink(Link $link, array $parameters = []): ResourceInterfa
/**
* {@inheritdoc}
*/
public function resolveLinkCollection(array $links, string $locale = \null): array
public function resolveLinkCollection(array $links, array $parameters = []): array
{
$locale = $parameters['locale'] ?? \null;

// We load all resources for the given resource types
$types = \array_unique(\array_map(function (Link $link) {
return $link->getLinkType();
Expand Down
6 changes: 3 additions & 3 deletions tests/Implementation/LinkResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public function resolveLink(Link $link, array $parameters = []): ResourceInterfa
/**
* {@inheritdoc}
*/
public function resolveLinkCollection(array $links, string $locale = \null): array
public function resolveLinkCollection(array $links, array $parameters = []): array
{
return \array_map(function (Link $link) use ($locale): ResourceInterface {
return $this->resolveLink($link, $locale);
return \array_map(function (Link $link) use ($parameters): ResourceInterface {
return $this->resolveLink($link, $parameters);
}, $links);
}
}
2 changes: 1 addition & 1 deletion tests/Unit/LinkResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ public function testInvalidLinkCollection()
{
$linkResolver = new LinkResolver(new MockClient(), new MockResourcePool());

$linkResolver->resolveLinkCollection([new Link('irrelevant', 'InvalidType')]);
$linkResolver->resolveLinkCollection([new Link('irrelevant', 'InvalidType')], []);
}
}

0 comments on commit d9ba2af

Please sign in to comment.