Created
June 21, 2012 13:51
-
-
Save leopro/2965848 to your computer and use it in GitHub Desktop.
Listener for image uploading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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