-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
DomCrawlerRFCRFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)
Description
Hi,
I suppose to change the \Closure by a callable and/or an array like [$this, 'methodName']
on the Crawler::each and Crawler::reduce, because it's really exhausting to inject all needed param by use ()
example:
$xml = <<<XML
<root>
<foo>
<bar>
<baz>baz1</baz>
<baz>baz2</baz>
</bar>
<bar>
<baz>baz3</baz>
</bar>
</foo>
</root>
XML;
$crawler = new Crawler($xml);
$neededParam1 = 'examplecontent';
$neededParam2 = 'examplecontent';
$crawler->children()->filterXPath('//root/foo')->each(function (Crawler $fooCrawler) use ($neededParam1, $neededParam2) {
// Do some operation
$fooCrawler->children()->filterXPath('bar')->each(function (Crawler $barCrawler) use ($neededParam1, $neededParam2) {
// Do some operation
$barCrawler->children()->filterXPath('baz')->each(function (Crawler $bazCrawler) use ($neededParam1, $neededParam2) {
// Do some operation with $neededParam1, $neededParam2
});
});
});
Metadata
Metadata
Assignees
Labels
DomCrawlerRFCRFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)