src/Behat/Behat/Snippet/SnippetWriter.php
public function printSnippets(SnippetPrinter $printer, array $snippets)
    {
        $printableSnippets = array();
        foreach ($snippets as $snippet) {
            foreach ($snippet->getTargets() as $target) {
                $targetSnippets = array();

                if (isset($printableSnippets[$target])) {
                    $targetSnippets = $printableSnippets[$target];
                }

                $targetSnippets[] = $snippet;
                $printableSnippets[$target] = $targetSnippets;
            }
        }

        foreach ($printableSnippets as $target => $targetSnippets) {
            $printer->printSnippets($target, $targetSnippets);
        }
    }
public function printSnippets(SnippetPrinter $printer, array $snippets)
    {
        $printableSnippets = array();
        foreach ($snippets as $snippet) {
            foreach ($snippet->getTargets() as $target) {
                $targetSnippets = array();

                if (isset($printableSnippets[$target])) {
                    $targetSnippets = $printableSnippets[$target];
                }

                $targetSnippets[] = $snippet;
                $printableSnippets[$target] = $targetSnippets;
            }
        }

        foreach ($printableSnippets as $target => $targetSnippets) {
            $printer->printSnippets($target, $targetSnippets);
        }
    }
public function printSnippets ( SnippetPrinter $ printer , array $ snippets ) { $ printableSnippets = array ( ) ; foreach ( $ snippets as $ snippet ) { foreach ( $ snippet -> getTargets ( ) as $ target ) { $ targetSnippets = array ( ) ; if ( isset ( $ printableSnippets [ $ target ] ) ) { $ targetSnippets = $ printableSnippets [ $ target ] ; } $ targetSnippets [ ] = $ snippet ; $ printableSnippets [ $ target ] = $ targetSnippets ; } } foreach ( $ printableSnippets as $ target => $ targetSnippets ) { $ printer -> printSnippets ( $ target , $ targetSnippets ) ; } }
Prints snippets using provided printer.

@param SnippetPrinter     $printer
@param AggregateSnippet[] $snippets
Prints snippets using provided printer .