Skip to content

Instantly share code, notes, and snippets.

@leopro
Created June 21, 2012 13:51
Show Gist options
  • Save leopro/2965848 to your computer and use it in GitHub Desktop.
Save leopro/2965848 to your computer and use it in GitHub Desktop.
Listener for image uploading
<?php
public function onFlush(OnFlushEventArgs $args)
{
$em = $args->getEntityManager();
$uow = $em->getUnitOfWork();
foreach ($uow->getScheduledEntityInsertions() as $entity) {
if ($entity instanceof ImageInterface) {
$filename = $this->manager->upload($entity);
$entity->setFilename($filename);
$metadata = $em->getClassMetadata(get_class($entity));
$uow->computeChangeSet($metadata, $entity);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment