[DomCrawler] Abstract URI logic and crawl images#17585
Conversation
|
About the tests, the only error I can see is about the framework bundle, any idea what I can do? |
|
👍 |
There was a problem hiding this comment.
Why is this constructor overriden?
There was a problem hiding this comment.
@jakzal the goal is to forbid passing the third argument. An Image is always a GET request
There was a problem hiding this comment.
@valeriangalliat yes, I think it would be more clear. I'm not gonna block this PR if you don't do this though ;)
|
@jakzal I got two other comments notification that you seem to have removed, I assume everything's okay? It was about existing code that I just moved around but still, if we can improve stuff here, I can update the PR. :) |
|
@valeriangalliat yeah, sorry for the noise. I noticed the code was moved and removed those comments. |
There was a problem hiding this comment.
We should make sure $node is an instance of \DOMElement, just like we do in the link() method.
|
Final remark: why do we need the |
|
Indeed, I would remove the interface. |
There was a problem hiding this comment.
Same opinion, but I kept consistency with
There was a problem hiding this comment.
@fabpot sure, I see it's present also in Crawler.php, Form.php and Field/FormField.php, should I remove it there too? Or I just edit AbstractUriElement.php and Crawler.php that are the only ones I changed in this PR?
There was a problem hiding this comment.
We could remove them in the existing class, but not in this PR. It should be done in older branches too.
There was a problem hiding this comment.
Just remove them in your own code for now.
|
@jakzal @fabpot Not sure why I added the interface, I just removed it. Also updated the PR according to comments. Just the |
All the URI parsing logic is externalized in the AbstractUriElement class. This class have two abstract methods: * setNode: validate the DOMElement node according to the concrete class rules, and set $this->node. * getRawUri: get the raw URI from $this->node. The Link classs now extends AbstractUriElement. This refactor is desirable for #12429.
A new Image class is added, extending AbstractUriElement, to leverage URI methods for the HTML img src attribute. Two methods are added to the Crawler class, image and images, that are the equivalent of link and links for images.
|
Thanks @valeriangalliat for working on this feature, this is much appreciated. |
…e a merge (jakzal) This PR was merged into the 3.1-dev branch. Discussion ---------- [Crawler] Remove a mention of an interface removed before a merge | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Missed it while merging #17585. Commits ------- 79a6a27 [Crawler] Remove a mention of an interface removed before a merge
This is a backward-compatible version of #13620, and a rebase of #13649 on current
master.