Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Api\SearchResults implement Api\SearchResultsInterface #1420

Merged
merged 1 commit into from
Jul 15, 2015
Merged

Make Api\SearchResults implement Api\SearchResultsInterface #1420

merged 1 commit into from
Jul 15, 2015

Conversation

Vinai
Copy link
Contributor

@Vinai Vinai commented Jun 27, 2015

Purpose

Make the implementation actually fulfill the contract defined by the interface.

Background

The return type hints of almost all the repository implementations of the getList()
method indicate a return type of \Magento\Framework\Api\SearchResultsInterface or
one of its sub-interfaces.

One example of many is \Magento\Catalog\Api\ProductRepositoryInterface::getList().
The return type hint states it returns \Magento\Catalog\Api\Data\ProductSearchResultsInterface,
which in turn extends \Magento\Framework\Api\SearchResultsInterface.

However, the concrete implementation preference for that interface is
\Magento\Framework\Api\SearchResults, which does not implement
\Magento\Framework\Api\SearchResultsInterface (or any interface for that matter).

Reasons for this PR

This PR makes Api\SearchResults actually implement Api\SearchResultsInterface,
forcing all implementations to match the contract.
It also improves developer experience because this is pretty much what should be expected
of the code.
It also makes the preference configuration technically more correct, because the configured
concrete class is guaranteed to at least partially fulfill the contract defined by the
interface.

Purpose
==

Make the implementation actually fulfill the contract defined by the interface.

Background
==

The return type hints of almost all the repository implementations of the `getList()`
method indicate a return type of `\Magento\Framework\Api\SearchResultsInterface` or
one of its sub-interfaces.

One example of many is `\Magento\Catalog\Api\ProductRepositoryInterface::getList()`.
The return type hint states it returns `\Magento\Catalog\Api\Data\ProductSearchResultsInterface`,
which in turn extends `\Magento\Framework\Api\SearchResultsInterface`.

However, the concrete implementation preference for that interface is
`\Magento\Framework\Api\SearchResults`, which does not implement
`\Magento\Framework\Api\SearchResultsInterface` (or any interface for that matter).

Reasons for this PR
==

This PR makes `Api\SearchResults` actually implement `Api\SearchResultsInterface`,
forcing all implementations to match the contract.
It also improves developer experience because this is pretty much what should be expected
of the code anyway.
It also makes the preference configuration technically more correct, because the configured
concrete class is guaranteed to at least partially fulfill the contract defined by the
interface.
@kokoc
Copy link
Member

kokoc commented Jul 7, 2015

@Vinai thank you for the contribution! Internal reference: MAGETWO-39813

@magento-team magento-team merged commit cbc85da into magento:develop Jul 15, 2015
@kokoc
Copy link
Member

kokoc commented Jul 16, 2015

@Vinai your code changes have just been deployed in version 1.0.0-beta. Thank you again for your contribution!

@Vinai Vinai deleted the api-searchresult-cleanup branch July 16, 2015 08:55
@Vinai
Copy link
Contributor Author

Vinai commented Jul 16, 2015

Thank you!

magento-team pushed a commit that referenced this pull request Aug 17, 2017
[EngCom] Public Pull Requests - 2.1
 - MAGETWO-71658: Fix for url_rewrite on page delete via api #10569
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants