[VarDumper] add caster for MongoCursor objects

This commit is contained in:
Nicolas Grekas 2015-03-24 09:20:54 +01:00
parent 1a4d7d7e48
commit 1008e6cdad
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,36 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\VarDumper\Caster;
use Symfony\Component\VarDumper\Cloner\Stub;
/**
* Casts classes from the MongoDb extension to array representation.
*
* @author Nicolas Grekas <p@tchwork.com>
*/
class MongoCaster
{
public static function castCursor(\MongoCursorInterface $cursor, array $a, Stub $stub, $isNested)
{
$prefix = "\0~\0";
if ($info = $cursor->info()) {
foreach ($info as $k => $v) {
$a[$prefix.$k] = $v;
}
}
$a[$prefix.'dead'] = $cursor->dead();
return $a;
}
}

View File

@ -76,6 +76,8 @@ abstract class AbstractCloner implements ClonerInterface
'SplObjectStorage' => 'Symfony\Component\VarDumper\Caster\SplCaster::castObjectStorage',
'SplPriorityQueue' => 'Symfony\Component\VarDumper\Caster\SplCaster::castHeap',
'MongoCursorInterface' => 'Symfony\Component\VarDumper\Caster\MongoCaster::castCursor',
':curl' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castCurl',
':dba' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castDba',
':dba persistent' => 'Symfony\Component\VarDumper\Caster\ResourceCaster::castDba',