Skip to content

Commit

Permalink
Merge pull request #47 from kevinpapst/config
Browse files Browse the repository at this point in the history
Fix cached config
  • Loading branch information
mxgross authored Sep 25, 2022
2 parents 22371fd + 457a546 commit e520e05
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 30 deletions.
22 changes: 10 additions & 12 deletions Configuration/EasyBackupConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,20 @@

namespace KimaiPlugin\EasyBackupBundle\Configuration;

use App\Configuration\StringAccessibleConfigTrait;
use App\Configuration\SystemBundleConfiguration;
use App\Configuration\SystemConfiguration;

class EasyBackupConfiguration implements SystemBundleConfiguration, \ArrayAccess
final class EasyBackupConfiguration
{
use StringAccessibleConfigTrait;
private $configuration;


public function getPrefix(): string
public function __construct(SystemConfiguration $configuration)
{
return 'easy_backup';
$this->configuration = $configuration;
}

public function getMysqlDumpCommand(): string
{
$config = $this->find('setting_mysqldump_command');
$config = $this->configuration->find('easybackup.setting_mysqldump_command');
if (!\is_string($config)) {
return 'NOT SET';
}
Expand All @@ -34,7 +32,7 @@ public function getMysqlDumpCommand(): string

public function getMysqlRestoreCommand(): string
{
$config = $this->find('setting_mysql_restore_command');
$config = $this->configuration->find('easybackup.setting_mysql_restore_command');
if (!\is_string($config)) {
return 'NOT SET';
}
Expand All @@ -43,8 +41,8 @@ public function getMysqlRestoreCommand(): string
}

public function getBackupDir(): string
{
$config = $this->find('setting_backup_dir');
{
$config = $this->configuration->find('easybackup.setting_backup_dir');
if (!\is_string($config)) {
return 'NOT SET';
}
Expand All @@ -54,7 +52,7 @@ public function getBackupDir(): string

public function getPathsToBeBackuped(): string
{
$config = $this->find('setting_paths_to_backup');
$config = $this->configuration->find('easybackup.setting_paths_to_backup');
if (!\is_string($config)) {
return 'NOT SET';
}
Expand Down
14 changes: 4 additions & 10 deletions Controller/EasyBackupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,12 @@ final class EasyBackupController extends AbstractController
*/
private $filesystem;

/**
* @var LoggerInterface
*/
private $logger;

public function __construct(string $dataDirectory, EasyBackupConfiguration $configuration, LoggerInterface $logger = null)
public function __construct(string $dataDirectory, EasyBackupConfiguration $configuration)
{
$this->kimaiRootPath = dirname(dirname($dataDirectory)).DIRECTORY_SEPARATOR;
$this->configuration = $configuration;
$this->dbUrl = $_SERVER['DATABASE_URL'];
$this->filesystem = new Filesystem();
$this->logger = $logger;
}

private function log($logLevel, $message)
Expand Down Expand Up @@ -296,7 +290,7 @@ public function restoreAction(Request $request)
$this->filesystem->remove($restoreDir);
} else {
$this->flashError('backup.action.filename.error');
$this->log(self::LOG_ERRROR_PREFIX, "Backup '$backupName' not found.");
$this->log(self::LOG_ERROR_PREFIX, "Backup '$backupName' not found.");
}

return $this->redirectToRoute('easy_backup');
Expand Down Expand Up @@ -397,7 +391,7 @@ private function restoreDirsAndFiles($restoreDir)
$this->log(self::LOG_ERROR_PREFIX, "Unable to copy to '$filenameAbsNew'. Please check the file permissions and try it again.");
}
} else {
$this->log(self::LOG_ERROR_PREFIX, "Failed to change permissions of '$filenameAbsNew' to '$filePermissions'.");
$this->log(self::LOG_ERROR_PREFIX, "Failed to change permissions of '$filenameAbsNew' to '$newFilePermissions'.");
}
}
}
Expand Down Expand Up @@ -505,7 +499,7 @@ private function unzip($source, $destination)
}
} else {
$this->flashError('backup.action.zip.error.extension');
$this->log(self::LOG_ERROR_PREFIX, "Extension '$zip' not found.");
$this->log(self::LOG_ERROR_PREFIX, "Extension ZIP not found.");
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Configuration implements ConfigurationInterface
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('easybackup');
/** @var ArrayNodeDefinition $rootNode */
Expand Down
1 change: 0 additions & 1 deletion DependencyInjection/EasyBackupExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function load(array $configs, ContainerBuilder $container)
$config = $this->processConfiguration($configuration, $configs);

$this->registerBundleConfiguration($container, $config);
$container->setParameter('easy_backup_settings', $config);

$loader = new Loader\YamlFileLoader(
$container,
Expand Down
2 changes: 1 addition & 1 deletion EventSubscriber/MenuSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function getSubscribedEvents(): array
/**
* @param \App\Event\ConfigureMainMenuEvent $event
*/
public function onMenuConfigure(ConfigureMainMenuEvent $event)
public function onMenuConfigure(ConfigureMainMenuEvent $event): void
{
$auth = $this->security;

Expand Down
2 changes: 1 addition & 1 deletion EventSubscriber/SystemConfigurationSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static function getSubscribedEvents()
];
}

public function onSystemConfiguration(SystemConfigurationEvent $event)
public function onSystemConfiguration(SystemConfigurationEvent $event): void
{
$event->addConfiguration(
(new SystemConfigurationModel())
Expand Down
4 changes: 0 additions & 4 deletions Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ services:
KimaiPlugin\EasyBackupBundle\Controller\:
resource: '../../Controller'
tags: ['controller.service_arguments']

KimaiPlugin\EasyBackupBundle\Configuration\EasyBackupConfiguration:
arguments:
$settings: '%easy_backup_settings%'

0 comments on commit e520e05

Please sign in to comment.