Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 1.66 KB

UPGRADE.md

File metadata and controls

29 lines (21 loc) · 1.66 KB

Upgrade from 1.x to 2.0

Several changes have been made to the public API in 2.0 in order to keep compatibility with Symfony 4.3:

  • HtmlPageCrawler::html() is now just the parent Crawler::html() and acts as getter only. Setting HTML content via HtmlPageCrawler::html($html) is not possible any more, use HtmlPageCrawler::setInnerHtml($html) instead

  • HtmlPageCrawler::text() is now just the parent Crawler::text() and acts as getter only that returns the text content from the first node only. For setting text content, use HtmlPageCrawler::setText($text) instead.

  • new method HtmlPageCrawler::getCombinedText() that returns the combined text from all nodes (as jQuery's text() function does and previous versions of HtmlPageCrawler::text() did)

  • HtmlPageCrawler::attr() is now just the parent Crawler::attr() and acts as getter only. For setting attributes use HtmlPageCrawler::setAttribute($name, $value)

  • removed method HtmlPageCrawler::isDisconnected()

To update your code, you have to:

  • replace all calls to $MyCrawlerInstance->html($html) used as setter by $MyCrawlerInstance->setInnerHtml($html)
  • replace all calls to $MyCrawlerInstance->attr($name, $value) used as setter by $MyCrawlerInstance->setAttribute($name, $value)
  • replace all calls to $MyCrawlerInstance->text($text) used as setter by $MyCrawlerInstance->setText($text)
  • replace all calls to $MyCrawlerInstance->text() (i.e. every call to text() not preceded by first()) by $MyCrawlerInstance->getCombinedText()
  • replace all calls to $MyCrawlerInstance->first()->text() by $MyCrawlerInstance->text()