Drupal investigation

DataCollector.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel\DataCollector;
  11. use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
  12. /**
  13. * DataCollector.
  14. *
  15. * Children of this class must store the collected data in the data property.
  16. *
  17. * @author Fabien Potencier <fabien@symfony.com>
  18. * @author Bernhard Schussek <bschussek@symfony.com>
  19. */
  20. abstract class DataCollector implements DataCollectorInterface, \Serializable
  21. {
  22. protected $data = array();
  23. /**
  24. * @var ValueExporter
  25. */
  26. private $valueExporter;
  27. public function serialize()
  28. {
  29. return serialize($this->data);
  30. }
  31. public function unserialize($data)
  32. {
  33. $this->data = unserialize($data);
  34. }
  35. /**
  36. * Converts a PHP variable to a string.
  37. *
  38. * @param mixed $var A PHP variable
  39. *
  40. * @return string The string representation of the variable
  41. */
  42. protected function varToString($var)
  43. {
  44. if (null === $this->valueExporter) {
  45. $this->valueExporter = new ValueExporter();
  46. }
  47. return $this->valueExporter->exportValue($var);
  48. }
  49. }