Release 2.20.0 (#4987)
This commit is contained in:
@@ -72,7 +72,7 @@ abstract class AbstractBundleInstallerCommand extends Command
|
||||
*/
|
||||
protected function getInstallerCommandName(): string
|
||||
{
|
||||
return sprintf('kimai:bundle:%s:install', $this->getBundleCommandNamePart());
|
||||
return \sprintf('kimai:bundle:%s:install', $this->getBundleCommandNamePart());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ abstract class AbstractBundleInstallerCommand extends Command
|
||||
|
||||
if ($parts[0] !== 'KimaiPlugin') {
|
||||
throw new LogicException(
|
||||
sprintf('Unsupported namespace given, expected "KimaiPlugin" but received "%s". Please overwrite getBundleName() and return the correct bundle name.', $parts[0])
|
||||
\sprintf('Unsupported namespace given, expected "KimaiPlugin" but received "%s". Please overwrite getBundleName() and return the correct bundle name.', $parts[0])
|
||||
);
|
||||
}
|
||||
|
||||
@@ -114,14 +114,14 @@ abstract class AbstractBundleInstallerCommand extends Command
|
||||
|
||||
$bundleName = $this->getBundleName();
|
||||
$io->title(
|
||||
sprintf('Starting installation of plugin: %s ...', $bundleName)
|
||||
\sprintf('Starting installation of plugin: %s ...', $bundleName)
|
||||
);
|
||||
|
||||
try {
|
||||
$this->importMigrations($io, $output);
|
||||
} catch (\Exception $ex) {
|
||||
$io->error(
|
||||
sprintf('Failed to install database for bundle %s. %s', $bundleName, $ex->getMessage())
|
||||
\sprintf('Failed to install database for bundle %s. %s', $bundleName, $ex->getMessage())
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
@@ -132,7 +132,7 @@ abstract class AbstractBundleInstallerCommand extends Command
|
||||
$this->installAssets($io, $output);
|
||||
} catch (\Exception $ex) {
|
||||
$io->error(
|
||||
sprintf('Failed to install assets for bundle %s. %s', $bundleName, $ex->getMessage())
|
||||
\sprintf('Failed to install assets for bundle %s. %s', $bundleName, $ex->getMessage())
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
@@ -142,7 +142,7 @@ abstract class AbstractBundleInstallerCommand extends Command
|
||||
chdir($path);
|
||||
|
||||
$io->success(
|
||||
sprintf('Congratulations! Plugin was successful installed: %s', $bundleName)
|
||||
\sprintf('Congratulations! Plugin was successful installed: %s', $bundleName)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
|
||||
@@ -51,9 +51,9 @@ final class ActivateUserCommand extends Command
|
||||
if (!$user->isEnabled()) {
|
||||
$user->setEnabled(true);
|
||||
$this->userService->saveUser($user);
|
||||
$io->success(sprintf('User "%s" has been activated.', $username));
|
||||
$io->success(\sprintf('User "%s" has been activated.', $username));
|
||||
} else {
|
||||
$io->warning(sprintf('User "%s" is already active.', $username));
|
||||
$io->warning(\sprintf('User "%s" is already active.', $username));
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
|
||||
@@ -67,7 +67,7 @@ final class ChangePasswordCommand extends AbstractUserCommand
|
||||
try {
|
||||
$user->setPlainPassword($password);
|
||||
$this->userService->updateUser($user, ['PasswordUpdate']);
|
||||
$io->success(sprintf('Changed password for user "%s".', $username));
|
||||
$io->success(\sprintf('Changed password for user "%s".', $username));
|
||||
} catch (ValidationFailedException $ex) {
|
||||
$this->validationError($ex, $io);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ final class CreateUserCommand extends AbstractUserCommand
|
||||
|
||||
try {
|
||||
$this->userService->saveUser($user);
|
||||
$io->success(sprintf('Success! Created user: %s', $username));
|
||||
$io->success(\sprintf('Success! Created user: %s', $username));
|
||||
} catch (ValidationFailedException $ex) {
|
||||
$this->validationError($ex, $io);
|
||||
|
||||
|
||||
@@ -51,9 +51,9 @@ final class DeactivateUserCommand extends Command
|
||||
if ($user->isEnabled()) {
|
||||
$user->setEnabled(false);
|
||||
$this->userService->saveUser($user);
|
||||
$io->success(sprintf('User "%s" has been deactivated.', $username));
|
||||
$io->success(\sprintf('User "%s" has been deactivated.', $username));
|
||||
} else {
|
||||
$io->warning(sprintf('User "%s" is already deactivated.', $username));
|
||||
$io->warning(\sprintf('User "%s" is already deactivated.', $username));
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
|
||||
@@ -40,17 +40,17 @@ final class DemoteUserCommand extends AbstractRoleCommand
|
||||
if ($user->isSuperAdmin()) {
|
||||
$user->setSuperAdmin(false);
|
||||
$userService->saveUser($user);
|
||||
$output->success(sprintf('Super administrator role has been removed from the user "%s".', $username));
|
||||
$output->success(\sprintf('Super administrator role has been removed from the user "%s".', $username));
|
||||
} else {
|
||||
$output->warning(sprintf('User "%s" doesn\'t have the super administrator role.', $username));
|
||||
$output->warning(\sprintf('User "%s" doesn\'t have the super administrator role.', $username));
|
||||
}
|
||||
} else {
|
||||
if ($user->hasRole($role)) {
|
||||
$user->removeRole($role);
|
||||
$userService->saveUser($user);
|
||||
$output->success(sprintf('Role "%s" has been removed from user "%s".', $role, $username));
|
||||
$output->success(\sprintf('Role "%s" has been removed from user "%s".', $role, $username));
|
||||
} else {
|
||||
$output->warning(sprintf('User "%s" didn\'t have "%s" role.', $username, $role));
|
||||
$output->warning(\sprintf('User "%s" didn\'t have "%s" role.', $username, $role));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,13 +35,13 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
final class ExportCreateCommand extends Command
|
||||
{
|
||||
public function __construct(
|
||||
private ServiceExport $serviceExport,
|
||||
private CustomerRepository $customerRepository,
|
||||
private ProjectRepository $projectRepository,
|
||||
private TeamRepository $teamRepository,
|
||||
private UserRepository $userRepository,
|
||||
private TranslatorInterface $translator,
|
||||
private MailerInterface $mailer
|
||||
private readonly ServiceExport $serviceExport,
|
||||
private readonly CustomerRepository $customerRepository,
|
||||
private readonly ProjectRepository $projectRepository,
|
||||
private readonly TeamRepository $teamRepository,
|
||||
private readonly UserRepository $userRepository,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private readonly MailerInterface $mailer
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -197,17 +197,19 @@ final class ExportCreateCommand extends Command
|
||||
$subject = 'Export data available';
|
||||
$body = 'Your exported data is available, please find it attached to this email.';
|
||||
|
||||
/** @var array<string> $emails */
|
||||
$emails = [];
|
||||
/** @var array<string> $tmp */
|
||||
$tmp = $input->getOption('email');
|
||||
if (\count($tmp) > 0) {
|
||||
foreach ($tmp as $email) {
|
||||
$result = filter_var($email, FILTER_VALIDATE_EMAIL);
|
||||
if ($result === false) {
|
||||
$io->error('Invalid "email" given: ' . $email);
|
||||
$io->error('Invalid "email" given');
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
$emails[] = $email;
|
||||
$emails[] = (string) $email;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +229,7 @@ final class ExportCreateCommand extends Command
|
||||
$user = $this->userRepository->loadUserByIdentifier($username);
|
||||
} catch(\Exception) {
|
||||
$io->error(
|
||||
sprintf('The given username "%s" could not be resolved', $username)
|
||||
\sprintf('The given username "%s" could not be resolved', $username)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
|
||||
@@ -73,7 +73,7 @@ final class InstallCommand extends Command
|
||||
}
|
||||
|
||||
$io->success(
|
||||
sprintf('Congratulations! Successfully installed %s version %s', Constants::SOFTWARE, Constants::VERSION)
|
||||
\sprintf('Congratulations! Successfully installed %s version %s', Constants::SOFTWARE, Constants::VERSION)
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
@@ -118,12 +118,12 @@ final class InstallCommand extends Command
|
||||
{
|
||||
try {
|
||||
if ($this->connection->isConnected()) {
|
||||
$io->note(sprintf('Database is existing and connection could be established'));
|
||||
$io->note(\sprintf('Database is existing and connection could be established'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->askConfirmation($input, $output, sprintf('Create the database "%s" (yes) or skip (no)?', $this->connection->getDatabase()), true)) {
|
||||
if (!$this->askConfirmation($input, $output, \sprintf('Create the database "%s" (yes) or skip (no)?', $this->connection->getDatabase()), true)) {
|
||||
throw new \Exception('Skipped database creation, aborting installation');
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
@@ -152,7 +152,7 @@ final class InstallCommand extends Command
|
||||
{
|
||||
/** @var QuestionHelper $questionHelper */
|
||||
$questionHelper = $this->getHelperSet()->get('question');
|
||||
$text = sprintf('<info>%s (yes/no)</info> [<comment>%s</comment>]:', $question, $default ? 'yes' : 'no');
|
||||
$text = \sprintf('<info>%s (yes/no)</info> [<comment>%s</comment>]:', $question, $default ? 'yes' : 'no');
|
||||
$question = new ConfirmationQuestion(' ' . $text . ' ', $default, '/^y|yes/i');
|
||||
|
||||
return $questionHelper->ask($input, $output, $question);
|
||||
|
||||
@@ -90,7 +90,7 @@ final class InvoiceCreateCommand extends Command
|
||||
$user = $this->userRepository->loadUserByIdentifier($username);
|
||||
} catch (\Exception $exception) {
|
||||
$io->error(
|
||||
sprintf('The given username "%s" could not be resolved', $username)
|
||||
\sprintf('The given username "%s" could not be resolved', $username)
|
||||
);
|
||||
|
||||
return Command::FAILURE;
|
||||
@@ -281,7 +281,7 @@ final class InvoiceCreateCommand extends Command
|
||||
|
||||
$tpl = $this->getTemplateForCustomer($input, $customer);
|
||||
if (null === $tpl) {
|
||||
$io->warning(sprintf('Could not find invoice template for project "%s", skipping!', $project->getName()));
|
||||
$io->warning(\sprintf('Could not find invoice template for project "%s", skipping!', $project->getName()));
|
||||
continue;
|
||||
}
|
||||
$query->setTemplate($tpl);
|
||||
@@ -293,7 +293,7 @@ final class InvoiceCreateCommand extends Command
|
||||
$invoices[] = $this->serviceInvoice->createInvoice($this->serviceInvoice->createModel($query), $this->eventDispatcher);
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$io->error(sprintf('Failed to create invoice for project "%s" with: %s', $project->getName(), $ex->getMessage()));
|
||||
$io->error(\sprintf('Failed to create invoice for project "%s" with: %s', $project->getName(), $ex->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ final class InvoiceCreateCommand extends Command
|
||||
|
||||
$tpl = $this->getTemplateForCustomer($input, $customer);
|
||||
if (null === $tpl) {
|
||||
$io->warning(sprintf('Could not find invoice template for customer "%s", skipping!', $customer->getName()));
|
||||
$io->warning(\sprintf('Could not find invoice template for customer "%s", skipping!', $customer->getName()));
|
||||
continue;
|
||||
}
|
||||
$query->setTemplate($tpl);
|
||||
@@ -364,7 +364,7 @@ final class InvoiceCreateCommand extends Command
|
||||
$invoices[] = $this->serviceInvoice->createInvoice($this->serviceInvoice->createModel($query), $this->eventDispatcher);
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$io->error(sprintf('Failed to create invoice for customer "%s" with: %s', $customer->getName(), $ex->getMessage()));
|
||||
$io->error(\sprintf('Failed to create invoice for customer "%s" with: %s', $customer->getName(), $ex->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ final class InvoiceCreateCommand extends Command
|
||||
$columns = ['Filename'];
|
||||
|
||||
$table = new Table($output);
|
||||
$table->setHeaderTitle(sprintf('Created %s invoice(s)', \count($invoices)));
|
||||
$table->setHeaderTitle(\sprintf('Created %s invoice(s)', \count($invoices)));
|
||||
$table->setHeaders($columns);
|
||||
|
||||
foreach ($invoices as $invoiceFile) {
|
||||
@@ -406,14 +406,14 @@ final class InvoiceCreateCommand extends Command
|
||||
$columns = ['ID', 'Customer', 'Total', 'Filename'];
|
||||
|
||||
$table = new Table($output);
|
||||
$table->setHeaderTitle(sprintf('Created %s invoice(s)', \count($invoices)));
|
||||
$table->setHeaderTitle(\sprintf('Created %s invoice(s)', \count($invoices)));
|
||||
$table->setHeaders($columns);
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
$file = $this->serviceInvoice->getInvoiceFile($invoice);
|
||||
if (null === $file) {
|
||||
$io->warning(
|
||||
sprintf('Created invoice with ID %s, but file was not found %s', $invoice->getId(), $invoice->getInvoiceFilename())
|
||||
\sprintf('Created invoice with ID %s, but file was not found %s', $invoice->getId(), $invoice->getInvoiceFilename())
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -40,17 +40,17 @@ final class PromoteUserCommand extends AbstractRoleCommand
|
||||
if (!$user->isSuperAdmin()) {
|
||||
$user->setSuperAdmin(true);
|
||||
$userService->saveUser($user);
|
||||
$output->success(sprintf('User "%s" has been promoted as a super administrator.', $username));
|
||||
$output->success(\sprintf('User "%s" has been promoted as a super administrator.', $username));
|
||||
} else {
|
||||
$output->warning(sprintf('User "%s" does already have the super administrator role.', $username));
|
||||
$output->warning(\sprintf('User "%s" does already have the super administrator role.', $username));
|
||||
}
|
||||
} else {
|
||||
if (!$user->hasRole($role)) {
|
||||
$user->addRole($role);
|
||||
$userService->saveUser($user);
|
||||
$output->success(sprintf('Role "%s" has been added to user "%s".', $role, $username));
|
||||
$output->success(\sprintf('Role "%s" has been added to user "%s".', $role, $username));
|
||||
} else {
|
||||
$output->warning(sprintf('User "%s" did already have "%s" role.', $username, $role));
|
||||
$output->warning(\sprintf('User "%s" did already have "%s" role.', $username, $role));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ final class RegenerateLocalesCommand extends Command
|
||||
*/
|
||||
private array $noRegionCode = ['ar', 'id', 'pa', 'sl'];
|
||||
/**
|
||||
* A list of locales that will be activated, not matter if translation files exist for them.
|
||||
* A list of locales that will be activated, no matter if translation files exist for them.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
|
||||
@@ -110,7 +110,7 @@ final class ReloadCommand extends Command
|
||||
}
|
||||
|
||||
$io->success(
|
||||
sprintf('Kimai config was reloaded')
|
||||
\sprintf('Kimai config was reloaded')
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
|
||||
@@ -38,7 +38,7 @@ final class TimesheetStopAllCommand extends Command
|
||||
|
||||
if (!$output->isQuiet()) {
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$io->success(sprintf('Stopped %s timesheet records.', $amount));
|
||||
$io->success(\sprintf('Stopped %s timesheet records.', $amount));
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
|
||||
@@ -28,7 +28,11 @@ use Symfony\Component\HttpClient\HttpClient;
|
||||
#[AsCommand(name: 'kimai:translations')]
|
||||
final class TranslationCommand extends Command
|
||||
{
|
||||
public function __construct(private string $projectDirectory, private string $kernelEnvironment, private LocaleService $localeService)
|
||||
public function __construct(
|
||||
private readonly string $projectDirectory,
|
||||
private readonly string $kernelEnvironment,
|
||||
private readonly LocaleService $localeService
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -70,6 +74,7 @@ final class TranslationCommand extends Command
|
||||
|
||||
$sources = [];
|
||||
if ($input->getOption('source') !== null) {
|
||||
/** @var string $tmp */
|
||||
$tmp = $input->getOption('source');
|
||||
foreach ($bases as $directory) {
|
||||
$files = glob($directory);
|
||||
@@ -95,6 +100,7 @@ final class TranslationCommand extends Command
|
||||
|
||||
$targets = [];
|
||||
if ($input->getOption('target') !== null) {
|
||||
/** @var string $tmp */
|
||||
$tmp = $input->getOption('target');
|
||||
foreach ($bases as $directory) {
|
||||
$files = glob($directory);
|
||||
@@ -402,7 +408,7 @@ final class TranslationCommand extends Command
|
||||
|
||||
$xmlContent = '';
|
||||
foreach ($translations as $id => $values) {
|
||||
$xmlContent .= sprintf(
|
||||
$xmlContent .= \sprintf(
|
||||
'<trans-unit id="%s" resname="%s"><source>%s</source><target>%s</target></trans-unit>',
|
||||
$id,
|
||||
$values['resname'],
|
||||
@@ -463,7 +469,7 @@ final class TranslationCommand extends Command
|
||||
|
||||
if (!\array_key_exists($key, $translations)) {
|
||||
throw new \Exception(
|
||||
sprintf('Missing english translation for key: %s in file %s', $key, $file)
|
||||
\sprintf('Missing english translation for key: %s in file %s', $key, $file)
|
||||
);
|
||||
}
|
||||
$unit->target[0] = $translations[$key];
|
||||
|
||||
@@ -91,7 +91,7 @@ final class UpdateCommand extends Command
|
||||
if ($cacheResult !== Command::SUCCESS) {
|
||||
$io->warning(
|
||||
[
|
||||
sprintf('Updated %s to version %s but the cache could not be rebuilt.', Constants::SOFTWARE, Constants::VERSION),
|
||||
\sprintf('Updated %s to version %s but the cache could not be rebuilt.', Constants::SOFTWARE, Constants::VERSION),
|
||||
'Please run the cache commands manually:',
|
||||
'bin/console cache:clear --env=' . $environment . PHP_EOL .
|
||||
'bin/console cache:warmup --env=' . $environment
|
||||
@@ -99,7 +99,7 @@ final class UpdateCommand extends Command
|
||||
);
|
||||
} else {
|
||||
$io->success(
|
||||
sprintf('Congratulations! Successfully updated %s to version %s', Constants::SOFTWARE, Constants::VERSION)
|
||||
\sprintf('Congratulations! Successfully updated %s to version %s', Constants::SOFTWARE, Constants::VERSION)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ final class VersionCommand extends Command
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
$io->writeln(sprintf('%s <info>%s</info> by Kevin Papst.', Constants::SOFTWARE, Constants::VERSION));
|
||||
$io->writeln(\sprintf('%s <info>%s</info> by Kevin Papst.', Constants::SOFTWARE, Constants::VERSION));
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user