Skip to content

Instantly share code, notes, and snippets.

@tyx
Created January 21, 2011 17:19
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 tyx/790022 to your computer and use it in GitHub Desktop.
Save tyx/790022 to your computer and use it in GitHub Desktop.
<?php
namespace App\GtsBundle\Form\Transformer;
use Symfony\Component\Form\ValueTransformer\BaseValueTransformer;
class DoctrineCollectionTransformer extends BaseValueTransformer
{
public function reverseTransform($ids, $collection)
{
return $collection;
}
/**
* @param Collection $value
*/
public function transform($value)
{
if ($value === null)
{
return new \Doctrine\Common\Collections\ArrayCollection;
}
return $value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment