Skip to content

Instantly share code, notes, and snippets.

Created December 18, 2012 07:35
Show Gist options
  • Save anonymous/4325868 to your computer and use it in GitHub Desktop.
Save anonymous/4325868 to your computer and use it in GitHub Desktop.
Simple NamerInterface implementation
<?php
namespace Screenfony\DemoBundle\Namer;
use Vich\UploaderBundle\Naming\NamerInterface;
/**
* Description of FileNamer
*
* @author ftassi
*/
class FileNamer implements NamerInterface
{
public function name($obj, $field)
{
/* @var $image \Symfony\Component\HttpFoundation\File\UploadedFile */
$method = 'get' . ucfirst($field);
$image = $obj->$method();
return uniqid() . '.' . $image->guessExtension();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment