Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.github export-ignore
/tests/ export-ignore
2 changes: 1 addition & 1 deletion .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
php: [ '7.4', '8.1' ]
php: [ '8.1', '8.3' ]
name: PHP ${{ matrix.php }}
steps:
- uses: actions/checkout@v2
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added|Changed|Deprecated|Removed|Fixed|Security
Nothing so far

## 10.0.0 - 2025-05-26
### Added
- Support for Symfony 6
- Support for Doctrine Persistence v3
### Removed
- Support for Symfony 5
- Support for PHP 7.4
- Support for Twig 2

## 9.1.0 - 2025-05-26
### Added
- Attribute implementation of File annotation
Expand Down
37 changes: 16 additions & 21 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,23 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"php": "^8",
"doctrine/orm": "^2 || ^3",
"doctrine/doctrine-bundle": "^2",
"doctrine/persistence": "^2",
"doctrine/persistence": "^2.13 || ^3",
"jms/metadata": "^2.1",
"symfony/config": "^5.4",
"symfony/console": "^5.4",
"symfony/dependency-injection": "^5.4",
"symfony/form": "^5.4",
"symfony/http-kernel": "^5.4",
"symfony/translation": "^5.4",
"symfony/framework-bundle": "^5.4",
"twig/twig": "^2.7 || ^3",
"symfony/config": "^6",
"symfony/console": "^6",
"symfony/dependency-injection": "^6",
"symfony/form": "^6",
"symfony/http-kernel": "^6",
"symfony/translation": "^6",
"symfony/framework-bundle": "^6",
"twig/twig": "^3",
"zicht/util": "^2"
},
"require-dev": {
"phpunit/phpunit": "^8 || ^9",
"zicht/standards-php": "^4"
"phpunit/phpunit": "^9.6"
},
"autoload": {
"psr-4": {
Expand All @@ -41,17 +40,13 @@
"minimum-stability": "stable",
"license": "MIT",
"scripts": {
"lint": [
"phpcs --standard=vendor/zicht/standards-php/phpcs.xml src/ tests/"
],
"lint-no-warn": [
"phpcs -n --standard=vendor/zicht/standards-php/phpcs.xml src/ tests/"
],
"lint-fix": [
"phpcbf --standard=vendor/zicht/standards-php/phpcs.xml src/ tests/"
],
"test": [
"phpunit tests/"
]
},
"extra": {
"branch-alias": {
"dev-feature-symfony-6": "10.x-dev"
}
}
}
26 changes: 11 additions & 15 deletions res/doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,26 @@ entity's 'avatar' field would become public/media/user/avatar/thefile.jpg.
## Installing ##

* Include zicht/filemanager-bundle in your composer.json configuration
* Add the bundle to your AppKernel
* Use the annotation in your model and annotate your property with it:
* Add the bundle to your bundles.php
* Use the attribute in your model and annotate your property with it:

use Zicht\Bundle\FileManagerBundle\Annotation\File;
use Zicht\Bundle\FileManagerBundle\Attribute\File;

// ....
/**
* @File
* @ORM\Column(type="string", nullable=true)
*/
#[File]
#[ORM\Column(type: 'string', nullable: true)]
protected $file;

## Doctrine ##

In your entity, specify the @File annotation (`Zicht\Bundle\FileManagerBundle\Doctrine\Annotation\File`) for a field:
In your entity, specify the @File attribute (`Zicht\Bundle\FileManagerBundle\Doctrine\Attribute\File`) for a field:

// ...
use Zicht\Bundle\FileManagerBundle\Doctrine\Annotation\File;
use Zicht\Bundle\FileManagerBundle\Doctrine\Attribute\File;
// ...

/**
* @ORM\Column(type="string", nullable=true)
* @File
*/
#[File]
#[ORM\Column(type: 'string', nullable: true)]
protected $photo = null;


Expand All @@ -57,9 +53,9 @@ You can refer files with the file_url() function. This function ignores the base
an imagine_filter. For regular files, you should an asset() function:

<img src="{{ file_url(user, 'avatar')|imagine_filter("avatar") }}" width="50" height="50" class="avatar">

<a href="{{ asset(file_url(document, 'file')) }}">Download this file</a>

## Using files as fixtures ##

If you're using datafixtures, you can use files as fixtures by wrapping them in the FixtureFile object. This object
Expand Down
27 changes: 8 additions & 19 deletions src/Command/CreateMimeFileCommand.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
<?php
/**
* @copyright Zicht Online <http://www.zicht.nl>
*/

namespace Zicht\Bundle\FileManagerBundle\Command;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Dumper;

#[AsCommand('zicht:filemanager:create:mime')]
class CreateMimeFileCommand extends Command
{
protected static $defaultName = 'zicht:filemanager:create:mime';
/** mime types */
private const MIME_FILE = '/etc/mime.types';

/**
* mime types
*/
const MIME_FILE = '/etc/mime.types';

/**
* {@inheritDoc}
*/
public function configure()
{
$this
Expand All @@ -37,11 +28,7 @@ public function configure()
);
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$dryRun = $input->getOption('dry-run');
$force = $input->getOption('force');
Expand Down Expand Up @@ -76,5 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
} elseif ($dryRun) {
echo $ymlDump;
}

return Command::SUCCESS;
}
}
33 changes: 10 additions & 23 deletions src/Command/FileCheckCommand.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php
/**
* @copyright Zicht Online <http://zicht.nl>
*/

namespace Zicht\Bundle\FileManagerBundle\Command;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -17,21 +15,14 @@
/**
* A command to check if the files in the database are in sync with the files on disk or vice versa.
*/
#[AsCommand('zicht:filemanager:check')]
class FileCheckCommand extends Command
{
protected static $defaultName = 'zicht:filemanager:check';
/**
* @var DatabaseChecker
*/
private $databaseChecker;
/**
* @var FilesystemChecker
*/
private $filesystemChecker;
/**
* @var EntityHelper
*/
private $entityHelper;
private DatabaseChecker $databaseChecker;

private FilesystemChecker $filesystemChecker;

private EntityHelper $entityHelper;

public function __construct(DatabaseChecker $databaseChecker, FilesystemChecker $filesystemChecker, EntityHelper $entityHelper, string $name = null)
{
Expand All @@ -41,9 +32,6 @@ public function __construct(DatabaseChecker $databaseChecker, FilesystemChecker
$this->entityHelper = $entityHelper;
}

/**
* {@inheritDoc}
*/
public function configure()
{
$this
Expand All @@ -59,10 +47,7 @@ public function configure()
);
}

/**
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
if ($input->getOption('inverse')) {
$checker = $this->databaseChecker;
Expand Down Expand Up @@ -90,5 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln("Checking entity {$entityClass}");
$checker->check($entityClass);
}

return Command::SUCCESS;
}
}
16 changes: 4 additions & 12 deletions src/Controller/ImagineController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php
/**
* @copyright Zicht Online <http://www.zicht.nl>
*/

namespace Zicht\Bundle\FileManagerBundle\Controller;

Expand All @@ -16,19 +13,14 @@
*/
class ImagineController extends AbstractController
{
public static function getSubscribedServices()
public static function getSubscribedServices(): array
{
return ['liip_imagine.cache.manager' => CacheManager::class] + parent::getSubscribedServices();
}

/**
* Remove thumbnail for given path
*
* @param Request $request
* @return JsonResponse
* @Route("/clear-thumbnail")
*/
public function clearThumbnailAction(Request $request)
/** Remove thumbnail for given path */
#[Route('/clear-thumbnail')]
public function clearThumbnailAction(Request $request): JsonResponse
{
$path = $request->get('path');
$filter = $request->get('filter');
Expand Down
7 changes: 1 addition & 6 deletions src/DependencyInjection/CompilerPass/SetOptionalDepsPass.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php
/**
* @copyright Zicht Online <http://zicht.nl>
*/

namespace Zicht\Bundle\FileManagerBundle\DependencyInjection\CompilerPass;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand All @@ -13,9 +11,6 @@
*/
class SetOptionalDepsPass implements CompilerPassInterface
{
/**
* {@inheritDoc}
*/
public function process(ContainerBuilder $container)
{
if ($container->hasDefinition('event_dispatcher') || $container->hasAlias('event_dispatcher')) {
Expand Down
5 changes: 1 addition & 4 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php
/**
* @copyright Zicht Online <http://www.zicht.nl>
*/

namespace Zicht\Bundle\FileManagerBundle\DependencyInjection;

Expand All @@ -21,7 +18,7 @@ public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('zicht_file_manager');
$rootNode = $treeBuilder->getRootNode();

$rootNode->children()
// Default behaviour is to lower case file names
->scalarNode('case_preservation')->defaultFalse();
Expand Down
6 changes: 0 additions & 6 deletions src/DependencyInjection/ZichtFileManagerExtension.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php
/**
* @copyright Zicht Online <http://zicht.nl>
*/

namespace Zicht\Bundle\FileManagerBundle\DependencyInjection;

Expand All @@ -19,9 +16,6 @@
*/
class ZichtFileManagerExtension extends DIExtension
{
/**
* {@inheritDoc}
*/
public function load(array $config, ContainerBuilder $container)
{
$configuration = new Configuration();
Expand Down
4 changes: 1 addition & 3 deletions src/Doctrine/EntityHelper.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php
/**
* @copyright Zicht Online <http://zicht.nl>
*/

namespace Zicht\Bundle\FileManagerBundle\Doctrine;

use Doctrine\Bundle\DoctrineBundle\Registry;
Expand Down
9 changes: 3 additions & 6 deletions src/Doctrine/FileManagerSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php
/**
* @copyright Zicht Online <http://zicht.nl>
*/

namespace Zicht\Bundle\FileManagerBundle\Doctrine;

Expand Down Expand Up @@ -58,7 +55,7 @@ public function getSubscribedEvents()
*/
public function preUpdate($eventArgs)
{
$entity = $eventArgs->getEntity();
$entity = $eventArgs->getObject();
$changeset = $eventArgs->getEntityChangeSet();

foreach ($this->metadata->getManagedFields($entity) as $field) {
Expand Down Expand Up @@ -102,7 +99,7 @@ function (FileManager $fm) use ($filepath) {
*/
public function preRemove($eventArgs)
{
$entity = $eventArgs->getEntity();
$entity = $eventArgs->getObject();
foreach ($this->metadata->getManagedFields($entity) as $field) {
$file = PropertyHelper::getValue($entity, $field);

Expand All @@ -125,7 +122,7 @@ public function preRemove($eventArgs)
*/
public function prePersist($eventArgs)
{
$entity = $eventArgs->getEntity();
$entity = $eventArgs->getObject();

foreach ($this->metadata->getManagedFields($entity) as $field) {
$value = PropertyHelper::getValue($entity, $field);
Expand Down
Loading