From ca8055e7b9ef557c39286f4c76ae49221c5d0c47 Mon Sep 17 00:00:00 2001 From: Gabi Udrescu Date: Thu, 2 Jan 2020 23:39:54 +0200 Subject: [PATCH] Add a storage abstraction layer --- composer.json | 1 + composer.lock | 189 ++++++++++++++++++++++++- config/bundles.php | 1 + config/packages/oneup_flysystem.yaml | 11 ++ config/packages/vich_uploader.yaml | 3 +- symfony.lock | 15 ++ templates/backend/form/theme.html.twig | 2 +- 7 files changed, 218 insertions(+), 4 deletions(-) create mode 100644 config/packages/oneup_flysystem.yaml diff --git a/composer.json b/composer.json index 0d7b915..a329dc3 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "guzzlehttp/guzzle": "^6.2", "knplabs/doctrine-behaviors": "~1.1", "liip/imagine-bundle": "^2.2", + "oneup/flysystem-bundle": "^3.3", "sensio/framework-extra-bundle": "^5.1", "sensiolabs/security-checker": "^5.0", "sonata-project/block-bundle": "^3.3", diff --git a/composer.lock b/composer.lock index 39e086e..ac72ff8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7b294149250ea68b87853e498d2a5c6b", + "content-hash": "f31cb89ff322b1b73f748e0f2dc75df5", "packages": [ { "name": "api-platform/api-pack", @@ -2949,6 +2949,90 @@ ], "time": "2019-06-17T12:58:15+00:00" }, + { + "name": "league/flysystem", + "version": "1.0.62", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem.git", + "reference": "14dd5d7dff5fbc29ca9a2a53ff109760e40d91a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/14dd5d7dff5fbc29ca9a2a53ff109760e40d91a0", + "reference": "14dd5d7dff5fbc29ca9a2a53ff109760e40d91a0", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "php": ">=5.5.9" + }, + "conflict": { + "league/flysystem-sftp": "<1.0.6" + }, + "require-dev": { + "phpspec/phpspec": "^3.4", + "phpunit/phpunit": "^5.7.10" + }, + "suggest": { + "ext-fileinfo": "Required for MimeType", + "ext-ftp": "Allows you to use FTP server storage", + "ext-openssl": "Allows you to use FTPS server storage", + "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2", + "league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3", + "league/flysystem-azure": "Allows you to use Windows Azure Blob storage", + "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching", + "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem", + "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files", + "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib", + "league/flysystem-webdav": "Allows you to use WebDAV storage", + "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter", + "spatie/flysystem-dropbox": "Allows you to use Dropbox storage", + "srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Flysystem\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frenky.net" + } + ], + "description": "Filesystem abstraction: Many filesystems, one API.", + "keywords": [ + "Cloud Files", + "WebDAV", + "abstraction", + "aws", + "cloud", + "copy.com", + "dropbox", + "file systems", + "files", + "filesystem", + "filesystems", + "ftp", + "rackspace", + "remote", + "s3", + "sftp", + "storage" + ], + "time": "2019-12-29T14:46:55+00:00" + }, { "name": "liip/imagine-bundle", "version": "2.2.0", @@ -3305,6 +3389,105 @@ ], "time": "2018-09-27T13:45:01+00:00" }, + { + "name": "oneup/flysystem-bundle", + "version": "3.3.0", + "source": { + "type": "git", + "url": "https://github.com/1up-lab/OneupFlysystemBundle.git", + "reference": "eb06fdc02362504702d162564c4c2b307ff30df0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/1up-lab/OneupFlysystemBundle/zipball/eb06fdc02362504702d162564c4c2b307ff30df0", + "reference": "eb06fdc02362504702d162564c4c2b307ff30df0", + "shasum": "" + }, + "require": { + "league/flysystem": "^1.0.26", + "php": "^7.0", + "symfony/framework-bundle": "^3.4|^4.0|^5.0" + }, + "require-dev": { + "jenko/flysystem-gaufrette": "^1.0", + "league/flysystem-aws-s3-v2": "^1.0", + "league/flysystem-azure-blob-storage": "^0.1", + "league/flysystem-cached-adapter": "^1.0", + "league/flysystem-gridfs": "^1.0", + "league/flysystem-memory": "^1.0", + "league/flysystem-rackspace": "^1.0", + "league/flysystem-replicate-adapter": "^1.0", + "league/flysystem-sftp": "^1.0", + "league/flysystem-webdav": "^1.0", + "league/flysystem-ziparchive": "^1.0", + "litipk/flysystem-fallback-adapter": "^0.1", + "phpunit/phpunit": "^6.4", + "spatie/flysystem-dropbox": "^1.0", + "superbalist/flysystem-google-storage": "^4.0", + "symfony/asset": "^3.4|^4.0|^5.0", + "symfony/browser-kit": "^3.4|^4.0|^5.0", + "symfony/finder": "^3.4|^4.0|^5.0", + "symfony/templating": "^3.4|^4.0|^5.0", + "symfony/translation": "^3.4|^4.0|^5.0", + "symfony/yaml": "^3.4|^4.0|^5.0", + "twistor/flysystem-stream-wrapper": "^1.0" + }, + "suggest": { + "ext-fileinfo": "Required for MimeType", + "ext-ftp": "Required for FTP and SFTP", + "jenko/flysystem-gaufrette": "Allows you to use gaufrette adapter", + "league/flysystem-aws-s3-v2": "Use S3 storage with AWS SDK v2", + "league/flysystem-aws-s3-v3": "Use S3 storage with AWS SDK v3", + "league/flysystem-azure-blob-storage": "Allows you to use Azure Blob Storage adapter", + "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching", + "league/flysystem-gridfs": "Allows you to use GridFS adapter", + "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files", + "league/flysystem-replicate-adapter": "Allows you to use the Replicate adapter from Flysystem", + "league/flysystem-sftp": "Allows SFTP server storage via phpseclib", + "league/flysystem-webdav": "Allows you to use WebDAV storage", + "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter", + "litipk/flysystem-fallback-adapter": "Allows you to use a fallback filesystem", + "spatie/flysystem-dropbox": "Use Dropbox storage", + "superbalist/flysystem-google-storage": "Allows you to use Google Cloud Storage buckets", + "twistor/flysystem-stream-wrapper": "Allows you to use stream wrapper" + }, + "type": "symfony-bundle", + "autoload": { + "psr-4": { + "Oneup\\FlysystemBundle\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jim Schmid", + "email": "js@1up.io", + "homepage": "https://1up.io", + "role": "Developer" + }, + { + "name": "David Greminger", + "email": "dg@1up.io", + "homepage": "https://1up.io", + "role": "Developer" + } + ], + "description": "Integrates Flysystem filesystem abstraction library to your Symfony project.", + "homepage": "https://1up.io", + "keywords": [ + "Flysystem", + "abstraction", + "filesystem", + "symfony" + ], + "time": "2019-12-06T16:27:51+00:00" + }, { "name": "pagerfanta/pagerfanta", "version": "v2.1.2", @@ -9574,6 +9757,7 @@ "code", "zf2" ], + "abandoned": "laminas/laminas-code", "time": "2018-08-13T20:36:59+00:00" }, { @@ -9628,6 +9812,7 @@ "events", "zf2" ], + "abandoned": "laminas/laminas-eventmanager", "time": "2018-04-25T15:33:34+00:00" }, { @@ -9674,6 +9859,7 @@ "stdlib", "zf" ], + "abandoned": "laminas/laminas-stdlib", "time": "2018-08-28T21:34:05+00:00" } ], @@ -10435,7 +10621,6 @@ ], "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", "homepage": "https://github.com/container-interop/container-interop", - "abandoned": "psr/container", "time": "2017-02-14T19:40:03+00:00" }, { diff --git a/config/bundles.php b/config/bundles.php index f828f4d..2841033 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -42,4 +42,5 @@ ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true], Vich\UploaderBundle\VichUploaderBundle::class => ['all' => true], + Oneup\FlysystemBundle\OneupFlysystemBundle::class => ['all' => true], ]; diff --git a/config/packages/oneup_flysystem.yaml b/config/packages/oneup_flysystem.yaml new file mode 100644 index 0000000..1c31ef6 --- /dev/null +++ b/config/packages/oneup_flysystem.yaml @@ -0,0 +1,11 @@ +# Read the documentation: https://github.com/1up-lab/OneupFlysystemBundle/tree/master/Resources/doc/index.md +oneup_flysystem: + adapters: + avatar_adapter: + local: + directory: '%kernel.project_dir%/public/media/avatar' + filesystems: + avatar_filesystem: + adapter: avatar_adapter + alias: League\Flysystem\Filesystem + mount: avatar_image_fs diff --git a/config/packages/vich_uploader.yaml b/config/packages/vich_uploader.yaml index 7a492dc..ead91e0 100644 --- a/config/packages/vich_uploader.yaml +++ b/config/packages/vich_uploader.yaml @@ -1,8 +1,9 @@ vich_uploader: db_driver: orm + storage: flysystem mappings: admin_avatar: uri_prefix: /media/avatar - upload_destination: '%kernel.project_dir%/public/media/avatar' + upload_destination: avatar_image_fs namer: Vich\UploaderBundle\Naming\OrignameNamer diff --git a/symfony.lock b/symfony.lock index d12fc6c..f9ce2ea 100644 --- a/symfony.lock +++ b/symfony.lock @@ -262,6 +262,9 @@ "lchrusciel/api-test-case": { "version": "v3.1.3" }, + "league/flysystem": { + "version": "1.0.62" + }, "liip/imagine-bundle": { "version": "1.8", "recipe": { @@ -338,6 +341,18 @@ "ocramius/proxy-manager": { "version": "2.2.0" }, + "oneup/flysystem-bundle": { + "version": "3.0", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "master", + "version": "3.0", + "ref": "0eb87bba411c227da027fe5f7c1dc7954b02f242" + }, + "files": [ + "config/packages/oneup_flysystem.yaml" + ] + }, "openlss/lib-array2xml": { "version": "0.0.10" }, diff --git a/templates/backend/form/theme.html.twig b/templates/backend/form/theme.html.twig index a230892..cc47ad4 100644 --- a/templates/backend/form/theme.html.twig +++ b/templates/backend/form/theme.html.twig @@ -69,7 +69,7 @@
{% if file.path|default(null) is not null %} - {{ form.vars.value.type }} + {{ form.vars.value.path }} {% endif %}