Symfony\Component\HttpKernel\DataCollector\DumpDataCollector::getDumps PHP Method

getDumps() public method

public getDumps ( $format, $maxDepthLimit, $maxItemsPerDepth )
    public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1)
    {
        $data = fopen('php://memory', 'r+b');
        if ('html' === $format) {
            $dumper = new HtmlDumper($data, $this->charset);
        } else {
            throw new \InvalidArgumentException(sprintf('Invalid dump format: %s', $format));
        }
        $dumps = array();
        foreach ($this->data as $dump) {
            if (method_exists($dump['data'], 'withMaxDepth')) {
                $dumper->dump($dump['data']->withMaxDepth($maxDepthLimit)->withMaxItemsPerDepth($maxItemsPerDepth));
            } else {
                // getLimitedClone is @deprecated, to be removed in 3.0
                $dumper->dump($dump['data']->getLimitedClone($maxDepthLimit, $maxItemsPerDepth));
            }
            rewind($data);
            $dump['data'] = stream_get_contents($data);
            ftruncate($data, 0);
            rewind($data);
            $dumps[] = $dump;
        }
        return $dumps;
    }

Usage Example

 /**
  * @param EndRequestEvent $event
  */
 public function onEndRequest(EndRequestEvent $event)
 {
     if (!$this->dumpCollector) {
         return;
     }
     $collection = $event->getDirectResponse();
     if (count($collection) < 1) {
         return;
     }
     $dumps = $this->dumpCollector->getDumps('html');
     if (empty($dumps)) {
         return;
     }
     $all = $collection->all();
     $all[0] = new DumpResponseDecorator($all[0], $dumps);
     $event->setDirectResponse(new ResponseCollection($all));
 }
All Usage Examples Of Symfony\Component\HttpKernel\DataCollector\DumpDataCollector::getDumps