Skip to content
Open
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
28 changes: 27 additions & 1 deletion Classes/Command/CleanupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,29 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use WebVision\WvFileCleanup\Domain\Repository\FileRepository;

/**
The symfony commands wv_file_cleanup:cleanup and wv_file_cleanup:emptyrecycler are available.

Example of using the command controllers from CLI context:
.vendor/bin/typo3 wv_file_cleanup:cleanup --help
.vendor/bin/typo3 wv_file_cleanup:cleanup 1:/ -r --verbose
.vendor/bin/typo3 wv_file_cleanup:cleanup 1:/Redaktion/Bilder/Aktuelles/2016/ -r --verbose --dry-run
.vendor/bin/typo3 wv_file_cleanup:emptyrecycler 1:/ -a 1month --verbose
To only match *.pdf files you can set the fileNameDenyPattern to /^(?!.*\b.pdf\b)/
.vendor/bin/typo3 wv_file_cleanup:cleanup 1:/ --verbose --dry-run --file-deny-pattern='/^(?!.*\b.pdf\b)/'

It is recommended to use the commands in a CLI context, but they can also be setup in the scheduler as scheduler tasks.

Options
You can configure an fileNameDenyPattern that holds a regular expression that is used to check the filename against. If the pattern matches the file is excluded from the cleanup and also not visible in het BE module.
Default value is /index.html/i so all index.html files are excluded and can be adjusted in the extension configuration (see extension manager).
The value can also be overwritten in the command controller (and scheduler task).
*/

/**
* Class CleanupCommand
*
* @package WebVision\WvFileCleanup\Command
*/
class CleanupCommand extends Command
{
Expand All @@ -25,8 +46,9 @@ class CleanupCommand extends Command
*/
protected FileRepository $fileRepository;

public function injectFileRepository(FileRepository $fileRepository): void
public function __construct(FileRepository $fileRepository)
{
parent::__construct();
$this->fileRepository = $fileRepository;
}

Expand Down Expand Up @@ -76,6 +98,10 @@ protected function configure(): void
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int
* @throws InsufficientFolderAccessPermissionsException
* @throws ResourceDoesNotExistException
*/
Expand Down
18 changes: 11 additions & 7 deletions Classes/Command/EmptyRecyclerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ class EmptyRecyclerCommand extends Command
/**
* @var FileRepository
*/
protected $fileRepository;
protected FileRepository $fileRepository;

/**
* @var ResourceFactory
*/
protected $resourceFactory;
protected ResourceFactory $resourceFactory;

public function injectFileRepository(FileRepository $fileRepository): void
public function __construct(
FileRepository $fileRepository,
ResourceFactory $resourceFactory
)
{
parent::__construct();
$this->fileRepository = $fileRepository;
}

public function injectResourceFactory(ResourceFactory $resourceFactory): void
{
$this->resourceFactory = $resourceFactory;
}

Expand Down Expand Up @@ -78,6 +78,10 @@ protected function configure(): void
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int
* @throws InsufficientFolderAccessPermissionsException
*/
protected function execute(InputInterface $input, OutputInterface $output): int
Expand Down
Loading