Jarves\Admin\ObjectCrud::translateFields PHP Method

translateFields() public method

Translate the label/title item of $fields.
public translateFields ( array | Field $fields )
$fields array | Jarves\Configuration\Field
    public function translateFields($fields)
    {
        if (is_array($fields)) {
            foreach ($fields as &$field) {
                $this->translateFields($field);
            }
        } elseif ($fields instanceof Field) {
            foreach (['label', 'desc'] as $prop) {
                $getter = 'get' . ucfirst($prop);
                $setter = 'set' . ucfirst($prop);
                if (is_callable([$fields, $getter]) && is_callable([$fields, $setter])) {
                    $value = $fields->{$getter}();
                    if (substr($value, 0, 2) == '[[' && substr($value, -2) == ']]') {
                        $fields->{$setter}($this->translator->t(substr($value, 2, -2)));
                    }
                }
            }
            if (is_array($fields->getChildren())) {
                $this->translateFields($fields->getChildren());
            }
        }
    }
ObjectCrud