Skip to content

Instantly share code, notes, and snippets.

@johnwards
Created April 18, 2011 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnwards/925912 to your computer and use it in GitHub Desktop.
Save johnwards/925912 to your computer and use it in GitHub Desktop.
<?php
namespace WhiteOctober\FormBuilderBundle\Normalizer;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
/**
* This handles unknown objects gracefully
*/
class noopNormalizer extends AbstractNormalizer
{
private $className = '';
/**
* {@inheritdoc}
*/
public function normalize($object, $format, $properties = null)
{
return array("Can not normalize ".$this->className);
}
/**
* {@inheritdoc}
*/
public function denormalize($data, $class, $format = null)
{
return "Can not denormalize ".$this->className;
}
/**
* Returns true all the time...this is just a rapid object to handle this
*
* @param string $format The format being (de-)serialized from or into.
* @return Boolean Whether the class has any getters.
*/
public function supports(\ReflectionClass $class, $format = null)
{
$this->className = $class->getName();
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment