Replace Locator and Content\Type\Sniffer with Content\Detector#849
Replace Locator and Content\Type\Sniffer with Content\Detector#849Art4 wants to merge 19 commits intosimplepie:masterfrom
Conversation
use Detector in SimplePie class
| use SimplePie\SimplePie; | ||
|
|
||
| /** | ||
| * Helper for feed auto-discovery and type sniffing |
There was a problem hiding this comment.
SimplePie\Locator internally depends on SimplePie\Content\Type\Sniffer, so by replacing the Locator class we also replace the Sniffer class.
| } | ||
|
|
||
| /** | ||
| * Check if the response contains a feed |
There was a problem hiding this comment.
| * Check if the response contains a feed | |
| * Check if the response body contains a feed |
There was a problem hiding this comment.
The Detector looks also into the headers and the requested uri to check if the Response contains a feed.
| public function discover_possible_feed_urls(Response $response, int $discovery_level = SimplePie::LOCATOR_ALL): array | ||
| { | ||
| /** @var Locator */ | ||
| $locator = $this->registry->create( |
There was a problem hiding this comment.
Unlike before, this creates a new locator entry for each method call. But it probably is not very costly and we only call the methods few times anyway.
| $discovered = null; | ||
| $checked_feeds = 0; | ||
|
|
||
| foreach ($possible_feed_urls as $href) { |
There was a problem hiding this comment.
I like having a pure (side-effect-free detector) but moving the effects to SimplePie class is not nice when it is already overly bloated. Could we have a separate helper class that would encapsulate this code?
90564b9 to
0836f14
Compare
In #731 we plan to deprecate the
SimplePie\Fileclass. The file class is required forSimplePie\LocatorandSimplePie\Content\Type\Sniffer, so the plan is to deprecate this classes too. See also the discussion in #826 (comment)This PR introduces a new interface
SimplePie\Content\Detectorthat defines the most features of the Locator and Sniffer in 3 methods.The
SimplePie\Content\VerfiedFeedsDetectorclass was created for BC. It internally uses the old Locator and Sniffer classes. This is needed because Locator and Sniffer classes could be replaced by the user using the Registry.A new
SimplePie\Content\UnverfiedFeedsDetectorhas to be created to replace the function of Locator and Sniffer. The idea is that this Detector should not have a dependency to a HTTP client but should only work withResponseclasses.This PR is under construction and requires some other PRs like #838 and a refactoring of the microformats handling in
SimplePie\SimplePie::fetch_data()