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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this as class PHP docblock does not make sense at all. I'd say
the command helptext needs to be adjusted to add explain this in more
detail.

Additionally, starting (adding) documentation (Documentation/) in
renderable state should be done and explain it in the documentation
along with adding it to the README.md file.

Going to have look on that when updatein the pull-request for the
required changes and rebasing it after extension repository is in
the correct state to merge this (branching out the 2.x branch).

.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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use the @package annotation in our extensions, similar to TYPO3 not using it within the core code. There is no real benefit of maintaining it.

And defining the "sobfolder" as own "package" does not make sense anyway.

Going to revert this when updating the pull-request.

*/
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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markijan

We prefer to use inject* method injection in commands to avoid
messing around with the constructor, which is defined by upstream
symfony component and may change any time.

Can you explain why you consideredto switch to constructor injection
here and missing the scalar nullable name argument not passing it down
to the parent call anyway ?

I'm going to revert this when streamlining/updateing the pull-request.

{
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
*
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like core we omit phpdocblock if native types are used until additional information are added, which is not the case here. Further we don't align
phpdocblock properties (column) for the argument name - similar to how it's
done within TYPO3 Core Development because we follow the core style making
extensions within our company an align the coding style to it.

Going to revert this when updating the pull-request.

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