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
31 changes: 4 additions & 27 deletions Classes/Command/DatabaseStorageCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,13 @@
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cli\CommandController;

/**
* @Flow\Scope("singleton")
*/
#[Flow\Scope("singleton")]
class DatabaseStorageCommandController extends CommandController
{
/**
* @var DatabaseStorageService
* @Flow\Inject
*/
#[Flow\Inject]
protected DatabaseStorageService $databaseStorageService;

/**
* @Flow\InjectConfiguration(package="Wegmeister.DatabaseStorage", path="cleanup")
* @var array|null
*/
#[Flow\InjectConfiguration(path: "cleanup", package: "Wegmeister.DatabaseStorage")]
protected ?array $storageCleanupConfiguration;

/**
Expand All @@ -47,12 +39,8 @@ public function cleanUpConfiguredStoragesCommand(): void
/**
* Deletes entries of all storages older than given date interval.
* You can also skip the configured storages.
*
* @param string $dateInterval
* @param bool $removeFiles
* @param bool $includeConfiguredStorages
*/
public function cleanupAllStoragesCommand(string $dateInterval, $removeFiles = false, bool $includeConfiguredStorages = false): void
public function cleanupAllStoragesCommand(string $dateInterval, bool $removeFiles = false, bool $includeConfiguredStorages = false): void
{
$this->outputFormatted('<b>Cleanup of all storages</b>');
$this->outputLine('');
Expand Down Expand Up @@ -89,11 +77,6 @@ public function cleanupAllStoragesCommand(string $dateInterval, $removeFiles = f
/**
* Get the cleanup results for the given storage identifiers.
* If no date interval is provided, the cleanup configuration will be used.
*
* @param array $storageIdentifiers
* @param DateInterval|null $dateInterval
* @param int $daysToKeepData
* @return array
*/
protected function getCleanupResultsForStorageIdentifier(array $storageIdentifiers, ?DateInterval $dateInterval = null, int $daysToKeepData = -1, $removeFiles = false): array
{
Expand Down Expand Up @@ -139,9 +122,6 @@ protected function getCleanupResultsForStorageIdentifier(array $storageIdentifie

/**
* Get the date interval from the configuration and ensure it is valid.
*
* @param string $storageIdentifier
* @return DateInterval
*/
protected function getDateIntervalFromConfiguration(string $storageIdentifier): DateInterval
{
Expand All @@ -168,9 +148,6 @@ protected function getDateIntervalFromConfiguration(string $storageIdentifier):

/**
* Get the amount of days to keep from the configured date interval
*
* @param DateInterval $dateInterval
* @return int
*/
protected function getDaysToKeepFromConfiguredInterval(DateInterval $dateInterval): int
{
Expand Down
73 changes: 13 additions & 60 deletions Classes/Controller/DatabaseStorageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@

/**
* The Database Storage controller
*
* @Flow\Scope("singleton")
*/
#[Flow\Scope("singleton")]
class DatabaseStorageController extends ActionController
{
/**
Expand Down Expand Up @@ -62,52 +61,18 @@ class DatabaseStorageController extends ActionController
],
];

/**
* Instance of the database storage repository.
*
* @Flow\Inject
* @var DatabaseStorageRepository
*/
protected $databaseStorageRepository;

/**
* @var DatabaseStorageService
*/
protected $databaseStorageService;
#[Flow\Inject]
protected DatabaseStorageRepository $databaseStorageRepository;

/**
* Instance of the translator interface.
*
* @Flow\Inject
* @var Translator
*/
protected $translator;
#[Flow\Inject]
protected Translator $translator;

/**
* Settings of this plugin.
*
* @var array
*/
protected $settings;

/**
* Inject the settings
*
* @param array $settings The settings to inject.
*
* @return void
*/
public function injectSettings(array $settings)
{
$this->settings = $settings;
}
protected DatabaseStorageService $databaseStorageService;

/**
* Show list of identifiers
*
* @return void
*/
public function indexAction()
public function indexAction(): void
{
$this->view->assign('identifiers', $this->databaseStorageRepository->findStorageidentifiers());
}
Expand All @@ -117,10 +82,8 @@ public function indexAction()
*
* @param string $identifier The storage identifier.
* @param int $currentPage
* @return void
* @throws StopActionException
*/
public function showAction(string $identifier, int $currentPage = 1)
public function showAction(string $identifier, int $currentPage = 1): void
{
$itemsPerPage = (int)($this->settings['itemsPerPage'] ?? 10);
$offset = ($currentPage - 1) * $itemsPerPage;
Expand Down Expand Up @@ -173,15 +136,9 @@ public function showAction(string $identifier, int $currentPage = 1)

/**
* Delete an entry from the list of identifiers.
*
* @param DatabaseStorage $entry The DatabaseStorage entry
*
* @return void
*/
public function deleteAction(
DatabaseStorage $entry,
bool $removeAttachedResources = false
) {
public function deleteAction(DatabaseStorage $entry, bool $removeAttachedResources = false): void
{
$identifier = $entry->getStorageidentifier();
$this->databaseStorageRepository->remove($entry, $removeAttachedResources);
$this->addFlashMessage(
Expand All @@ -202,11 +159,9 @@ public function deleteAction(
*
* @param string $identifier The storage identifier for the entries to be removed.
* @param bool $redirect Redirect to index?
* @param bool $removeAttachedResource Remove attached resources?
*
* @return void
* @param bool $removeAttachedResources Remove attached resources?
*/
public function deleteAllAction(string $identifier, bool $redirect = false, bool $removeAttachedResources = false)
public function deleteAllAction(string $identifier, bool $redirect = false, bool $removeAttachedResources = false): void
{
$count = $this->databaseStorageRepository->deleteByStorageIdentifierAndDateInterval(
$identifier,
Expand Down Expand Up @@ -239,10 +194,8 @@ public function deleteAllAction(string $identifier, bool $redirect = false, bool
* @param string $identifier The storage identifier that should be exported.
* @param string $writerType The writer type/export format to be used.
* @param bool $exportDateTime Should the datetime be exported?
*
* @return void
*/
public function exportAction(string $identifier, string $writerType = 'Xlsx', bool $exportDateTime = false)
public function exportAction(string $identifier, string $writerType = 'Xlsx', bool $exportDateTime = false): void
{
if (!isset(self::$types[$writerType])) {
throw new WriterException('No writer available for type ' . $writerType . '.', 1521787983);
Expand Down
59 changes: 9 additions & 50 deletions Classes/Domain/Model/DatabaseStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
use Neos\Flow\Annotations as Flow;
use Doctrine\ORM\Mapping as ORM;

/**
* @Flow\Entity
*/
#[Flow\Entity]
class DatabaseStorage
{

Expand All @@ -42,77 +40,38 @@ class DatabaseStorage
protected $properties = [];

/**
* DateTime the entry was created.
*
* @var \DateTime
* @Flow\Validate(type="NotEmpty")
*/
protected $datetime;
protected \DateTime $datetime;

/**
* Get identifier
*
* @return string
*/
public function getStorageidentifier()
public function getStorageidentifier(): string
{
return $this->storageidentifier;
}

/**
* Set the identifier
*
* @param string $identifier The identifier for the entry.
*
* @return DatabaseStorage
*/
public function setStorageidentifier(string $identifier)
public function setStorageidentifier(string $storageIdentifier): DatabaseStorage
{
$this->storageidentifier = $identifier;
$this->storageidentifier = $storageIdentifier;
return $this;
}

/**
* Get properties
*
* @return array
*/
public function getProperties()
public function getProperties(): array
{
return $this->properties;
}

/**
* Set properties
*
* @param array $properties Array of the properties.
*
* @return DatabaseStorage
*/
public function setProperties(array $properties)
public function setProperties(array $properties): DatabaseStorage
{
$this->properties = $properties;
return $this;
}

/**
* Get datetime
*
* @return \DateTime
*/
public function getDateTime()
public function getDateTime(): \DateTime
{
return $this->datetime;
}

/**
* Set datetime
*
* @param \DateTime $datetime
*
* @return DatabaseStorage
*/
public function setDateTime(\DateTime $datetime)
public function setDateTime(\DateTime $datetime): DatabaseStorage
{
$this->datetime = $datetime;
return $this;
Expand Down
Loading