Andrew13\Cabinet\CabinetUpload::process PHP Méthode

process() public méthode

public process ( Symfony\Component\HttpFoundation\File\UploadedFile $file )
$file Symfony\Component\HttpFoundation\File\UploadedFile
    public function process(UploadedFile $file)
    {
        // File extension
        $this->extension = $file->getClientOriginalExtension();
        // Mimetype for the file
        $this->mimetype = $file->getMimeType();
        // Current user or 0
        $this->user_id = Auth::user() ? Auth::user()->id : 0;
        $this->size = $file->getSize();
        list($this->path, $this->filename) = $this->upload($file);
        $this->save();
        // Check to see if image thumbnail generation is enabled
        if (static::$app['config']->get('cabinet::image_manipulation')) {
            $thumbnails = $this->generateThumbnails($this->path, $this->filename);
            $uploads = array();
            foreach ($thumbnails as $thumbnail) {
                $upload = new $this();
                $upload->filename = $thumbnail->fileSystemName;
                $upload->path = static::$app['config']->get('cabinet::upload_folder_public_path') . $this->dateFolderPath . $thumbnail->fileSystemName;
                // File extension
                $upload->extension = $thumbnail->getClientOriginalExtension();
                // Mimetype for the file
                $upload->mimetype = $thumbnail->getMimeType();
                // Current user or 0
                $upload->user_id = $this->user_id;
                $upload->size = $thumbnail->getSize();
                $upload->parent_id = $this->id;
                $upload->save();
                $uploads[] = $upload;
            }
            $this->children = $uploads;
        }
    }