/**
  * This file get anotations data and will resize pictures before save new data.
  * @param \Doctrine\ORM\Event\LifecycleEventArgs $args
  */
 private function uploadProcess(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     /* get Entities annotation's data */
     $aAnnotations = ImgResizeReader::hydrateObject(get_class($entity), $entity);
     foreach ($aAnnotations as $annotation) {
         if (!empty($annotation[0])) {
             $sGetterImg = "get" . ucfirst($annotation[1]);
             $oResize = new Upload($annotation[0], $entity->{$sGetterImg}(), $this->public_path);
             $newImgName = $oResize->getImgNewName();
             $setterProperty = 'set' . ucfirst($annotation[0]->saveField);
             if ($newImgName != '' && !is_null($newImgName)) {
                 $entity->{$setterProperty}($newImgName);
             }
         }
     }
 }
 function testAnnotationRead()
 {
     $entity = new Article();
     $reader = ImgResizeReader::hydrateObject(get_class($entity), $entity);
     $this->assertEquals(count($reader), 1);
     //nb annotations
     $this->assertInstanceOf('Weysan\\DoctrineImgBundle\\Annotations\\ImgResize', $reader[0][0]);
     //annotation class
     $this->assertEquals($reader[0][1], 'image');
     //annotation field
     //resize property check
     $resize = $reader[0][0];
     $this->assertEquals($resize->width, 500);
     $this->assertEquals($resize->height, 300);
     $this->assertEquals($resize->uploadDir, 'media/upload/article');
     $this->assertEquals($resize->saveField, 'path');
     $this->assertEquals($resize->value, 'image');
 }