Common\Doctrine\ValueObject\AbstractFile::upload PHP Метод

upload() публичный Метод

This function should be called for the life cycle events @ORM\PostPersist() and @ORM\PostUpdate()
public upload ( )
    public function upload()
    {
        // check if we have an old image
        if ($this->oldFileName !== null) {
            $this->removeOldFile();
        }
        if ($this->getFile() === null) {
            return;
        }
        $this->writeFileToDisk();
        $this->file = null;
    }

Usage Example

Пример #1
0
 /**
  * This function should be called for the life cycle events @ORM\PostPersist() and @ORM\PostUpdate()
  */
 public function upload()
 {
     $file = $this->getFile();
     parent::upload();
     if (static::GENERATE_THUMBNAILS && $file instanceof UploadedFile) {
         Model::generateThumbnails(FRONTEND_FILES_PATH . '/' . $this->getTrimmedUploadDir(), $this->getAbsolutePath('source'));
     }
 }