68publishers / file-bundle
File management bundle based on our file-storage for Nette Framework.
Requires
- php: ^8.3
- ext-fileinfo: *
- 68publishers/doctrine-bridge: ^2.0
- 68publishers/doctrine-persistence: ^0.4
- 68publishers/event-dispatcher-extra: ^1.4
- 68publishers/file-storage: ^2.0
- 68publishers/smart-nette-component: ^2.0
- 68publishers/translation-bridge: ^3.0
- doctrine/orm: ^2.16 || ^3.0
- nette/application: ^3.1.10
- nette/di: ^3.1.3
- nette/http: ^3.1
- nette/schema: ^1.2
- nette/utils: ^3.2.10 || ^4.0.1
- ramsey/uuid: ^4.0
- symfony/event-dispatcher: ^6.4.3 || ^7.0 || ^8.0
Requires (Dev)
- 68publishers/image-storage: ^2.0
- 68publishers/notification-bundle: ^0.4
- doctrine/annotations: ^1.13 || ^2.0
- friendsofphp/php-cs-fixer: ^3.75
- gedmo/doctrine-extensions: ^3.5
- latte/latte: ^3.0
- nette/bootstrap: ^3.1
- nette/tester: ^2.6
- roave/security-advisories: dev-latest
- symfony/var-exporter: ^6.4 || ^7.0
Suggests
- 68publishers/image-storage: Use combination of file-storage and image-storage to better management of images!
- 68publishers/notification-bundle: For automatic notifications (flash message, toastr) on file upload, deletion etc.
- gedmo/doctrine-extensions: If you want to use soft-deletable files.
Provides
None
Conflicts
Replaces
None
README
⚠️ Warning! This package does not have active support, it exists only for the historical needs of the author.
File Bundle
🌆 File management bundle based on our file-storage for Nette Framework.
Installation
The best way to install 68publishers/file-bundle is using Composer:
composer require 68publishers/file-bundle
Requirements: PHP ^8.3, doctrine/orm ^2.16 || ^3.0, nette/application ^3.1.10. The soft-deletable entity requires gedmo/doctrine-extensions ^3.5.
The entities are mapped with PHP attributes and registered through 68publishers/doctrine-bridge with the attribute driver (EntityMapping::DRIVER_ATTRIBUTE), so a mapping driver service of the type Doctrine\ORM\Mapping\Driver\AttributeDriver must exist in the container. Applications that map their own entities with annotations (doctrine/orm 2) only need to register it next to the annotation driver, e.g.:
services: attributeDriver: factory: Doctrine\ORM\Mapping\Driver\AttributeDriver([], true) autowired: false
or use Nettrine\ORM\DI\OrmAttributesExtension of nettrine/orm (the bridge option 68publishers.doctrine_bridge.services.drivers.attribute selects the driver service if there are more of them). Annotation-mapped application entities can still extend or relate to the package entities. The driver must be created with reportFieldsWhereDeclared: true (the second argument, the only mode of doctrine/orm 3), otherwise an annotation-mapped entity extending AbstractFile has no fields of the superclass ("No identifier/primary key specified"). OrmAttributesExtension of nettrine/orm 0.8 creates the driver without it.
Configuration
extensions: 68publishers.file_bundle: SixtyEightPublishers\FileBundle\DI\FileBundleExtension 68publishers.file_bundle: entity: SixtyEightPublishers\FileBundle\Entity\Basic\File file_managers: default: template: '@fileManagerControl.latte' # a template relative to the default templates directory or an absolute path actions: - SixtyEightPublishers\FileBundle\Action\DownloadAction readonly: extends: default # inherits all options of the file manager `default`, lists (actions, manipulators...) are merged max_allowed_files: 1
The extended file manager must be defined in the same configuration file.
Upgrade
From 0.5 to 0.6
- The minimal PHP version is 8.3.
- The package requires
68publishers/doctrine-bridge^2.0,68publishers/doctrine-persistence^0.4,68publishers/event-dispatcher-extra^1.4,68publishers/file-storage^2.0,68publishers/smart-nette-component^2.0and68publishers/translation-bridge^3.0. - The integrations of
68publishers/image-storageand68publishers/notification-bundleneed versions compatible with the packages above (image-storage1.x requiresfile-storage^1.4,notification-bundle0.3 requiressmart-nette-component^1.0andtranslation-bridge^2.0). nette/formsis no longer required. Require it in your project if you use it.- The entities are mapped with PHP attributes instead of annotations (the database schema is the same) and
doctrine/orm3 is supported. Register a service of the typeDoctrine\ORM\Mapping\Driver\AttributeDriver(see Installation), otherwise the container compilation fails with "Can't resolve service definition ... services.drivers.attribute". - If you use your own entity that extends
AbstractFile, the mapped superclass is now registered too. Its lifecycle callbackonPreUpdate()(updatesupdatedand the source version) is now called for your entity as well, the annotation driver ignored it before. doctrine/orm2.16 is the minimal version (see above).doctrine/annotationsis no longer required. The soft-deletable entity requiresgedmo/doctrine-extensions^3.5(attributes support).TranslatableHtmlStringInterface::setTranslator()acceptsNette\Localization\TranslatorandDropZoneControl::addContentHtml()acceptsNette\HtmlStringable(the deprecatedITranslatorandIHtmlStringare aliases of them, existing implementations keep working).
Contributing
Before committing any changes, don't forget to run
vendor/bin/php-cs-fixer fix -v --dry-run
and
vendor/bin/tester ./tests