original_string: public function preRemove($eventArgs)
      {
          $entity = $eventArgs->getEntity();
          foreach ($this->metadata->getManagedFields($entity) as $field) {
              $file = PropertyHelper::getValue($entity, $field);
  
              if ($file) {
                  $filepath = $this->fileManager->getFilePath($entity, $field, $file);
  
                  $this->unitOfWork[spl_object_hash($entity)][$field]['delete'] = function (FileManager $fm) use ($filepath) {
                      $fm->delete($filepath);
                  };
              }
          }
      }
code: public function preRemove($eventArgs)
      {
          $entity = $eventArgs->getEntity();
          foreach ($this->metadata->getManagedFields($entity) as $field) {
              $file = PropertyHelper::getValue($entity, $field);
  
              if ($file) {
                  $filepath = $this->fileManager->getFilePath($entity, $field, $file);
  
                  $this->unitOfWork[spl_object_hash($entity)][$field]['delete'] = function (FileManager $fm) use ($filepath) {
                      $fm->delete($filepath);
                  };
              }
          }
      }
code_tokens: public function preRemove ( $ eventArgs ) { $ entity = $ eventArgs -> getEntity ( ) ; foreach ( $ this -> metadata -> getManagedFields ( $ entity ) as $ field ) { $ file = PropertyHelper :: getValue ( $ entity , $ field ) ; if ( $ file ) { $ filepath = $ this -> fileManager -> getFilePath ( $ entity , $ field , $ file ) ; $ this -> unitOfWork [ spl_object_hash ( $ entity ) ] [ $ field ] [ 'delete' ] = function ( FileManager $ fm ) use ( $ filepath ) { $ fm -> delete ( $ filepath ) ; } ; } } }
docstring: Removes the files attached to the entity
  
  @param LifeCycleEventArgs $eventArgs
  @return void
docstring_tokens: Removes the files attached to the entity