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);
                };
            }
        }
    }
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);
                };
            }
        }
    }
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 ) ; } ; } } }
Removes the files attached to the entity

@param LifeCycleEventArgs $eventArgs
@return void
Removes the files attached to the entity