Skip to content

Commit

Permalink
IControl: removed translate(), it is just part of BaseControl
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jun 30, 2016
1 parent 4473513 commit d260d62
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
8 changes: 0 additions & 8 deletions src/Forms/IControl.php
Expand Up @@ -44,12 +44,4 @@ function getErrors();
*/
function isOmitted();

/**
* Returns translated string.
* @param string
* @param int plural count
* @return string
*/
function translate($s, $count = NULL);

}
10 changes: 8 additions & 2 deletions src/Forms/Rendering/DefaultFormRenderer.php
Expand Up @@ -381,7 +381,10 @@ public function renderPairMulti(array $controls)
$description = ' ' . $control->getOption('description');

} elseif (is_string($description)) {
$description = ' ' . $this->getWrapper('control description')->setText($control->translate($description));
if ($control instanceof Nette\Forms\Controls\BaseControl) {
$description = $control->translate($description);
}
$description = ' ' . $this->getWrapper('control description')->setText($description);

} else {
$description = '';
Expand Down Expand Up @@ -437,7 +440,10 @@ public function renderControl(Nette\Forms\IControl $control)
$description = ' ' . $description;

} elseif (is_string($description)) {
$description = ' ' . $this->getWrapper('control description')->setText($control->translate($description));
if ($control instanceof Nette\Forms\Controls\BaseControl) {
$description = $control->translate($description);
}
$description = ' ' . $this->getWrapper('control description')->setText($description);

} else {
$description = '';
Expand Down
4 changes: 2 additions & 2 deletions src/Forms/Validator.php
Expand Up @@ -67,7 +67,7 @@ public static function formatMessage(Rule $rule, $withValue = TRUE)
static $i = -1;
switch ($m[1]) {
case 'name': return $rule->control->getName();
case 'label': return $rule->control->translate($rule->control->caption);
case 'label': return $rule->control instanceof Controls\BaseControl ? $rule->control->translate($rule->control->caption) : NULL;
case 'value': return $withValue ? $rule->control->getValue() : $m[0];
default:
$args = is_array($rule->arg) ? $rule->arg : [$rule->arg];
Expand Down Expand Up @@ -135,7 +135,7 @@ public static function validateBlank(IControl $control)
* Is control valid?
* @return bool
*/
public static function validateValid(IControl $control)
public static function validateValid(Controls\BaseControl $control)
{
return $control->getRules()->validate();
}
Expand Down

0 comments on commit d260d62

Please sign in to comment.