Skip to content

Commit

Permalink
QuickBaseForm: Replace method translate with trait
Browse files Browse the repository at this point in the history
The trait provides translatePlural method.
  • Loading branch information
sukhwinder33445 committed Apr 19, 2024
1 parent d85fdd7 commit 8082f7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
14 changes: 7 additions & 7 deletions application/forms/CleanupNodeForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ public function onSuccess()
$changes->deleteNode($node);
}

$count = count($nodesToCleanup);
if ($count === 1) {
$successMsg = sprintf($this->translate('Successfully removed missing node %s'), $nodeName);
} else {
$successMsg = sprintf($this->translate('Successfully removed %d missing nodes'), $count);
}

$this->setSuccessMessage($successMsg);
$count = count($nodesToCleanup);
$this->setSuccessMessage($this->translatePlural(
'Successfully removed missing node %s',
'Successfully removed %d missing nodes',
$count,
$count > 1 ? $count : $nodeName

Check failure on line 65 in application/forms/CleanupNodeForm.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Parameter #4 $context of method Icinga\Module\Businessprocess\Web\Form\QuickBaseForm::translatePlural() expects string|null, int<2, max>|string|null given.

Check failure on line 65 in application/forms/CleanupNodeForm.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Parameter #4 $context of method Icinga\Module\Businessprocess\Web\Form\QuickBaseForm::translatePlural() expects string|null, int<2, max>|string|null given.

Check failure on line 65 in application/forms/CleanupNodeForm.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Parameter #4 $context of method Icinga\Module\Businessprocess\Web\Form\QuickBaseForm::translatePlural() expects string|null, int<2, max>|string|null given.

Check failure on line 65 in application/forms/CleanupNodeForm.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Parameter #4 $context of method Icinga\Module\Businessprocess\Web\Form\QuickBaseForm::translatePlural() expects string|null, int<2, max>|string|null given.

Check failure on line 65 in application/forms/CleanupNodeForm.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Parameter #4 $context of method Icinga\Module\Businessprocess\Web\Form\QuickBaseForm::translatePlural() expects string|null, int<2, max>|string|null given.

Check failure on line 65 in application/forms/CleanupNodeForm.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Parameter #4 $context of method Icinga\Module\Businessprocess\Web\Form\QuickBaseForm::translatePlural() expects string|null, int<2, max>|string|null given.

Check failure on line 65 in application/forms/CleanupNodeForm.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Parameter #4 $context of method Icinga\Module\Businessprocess\Web\Form\QuickBaseForm::translatePlural() expects string|null, int<2, max>|string|null given.
));

unset($changes);

Expand Down
12 changes: 3 additions & 9 deletions library/Businessprocess/Web/Form/QuickBaseForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
use Icinga\Application\Icinga;
use Icinga\Application\Modules\Module;
use ipl\Html\ValidHtml;
use ipl\I18n\Translation;
use Zend_Form;

abstract class QuickBaseForm extends Zend_Form implements ValidHtml
{
use Translation;

/**
* The Icinga module this form belongs to. Usually only set if the
* form is initialized through the FormLoader
Expand Down Expand Up @@ -154,13 +157,4 @@ protected function valueIsEmpty($value)

return strlen($value) === 0;
}

public function translate($string)
{
if ($this->icingaModuleName === null) {
return t($string);
} else {
return mt($this->icingaModuleName, $string);
}
}
}

0 comments on commit 8082f7d

Please sign in to comment.