Completed
Push — master ( 4e2c55...2c21d8 )
by Andrey
01:28
created

src/views/fieldsMultilanguage.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by Andrey Girnik
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 15 and the first side effect is on line 20.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
use yii\base\Model;
4
use yii\helpers\ArrayHelper;
5
use yii\widgets\ActiveForm;
6
use Itstructure\FieldWidgets\FieldType;
7
use Itstructure\FieldWidgets\interfaces\{LanguageListInterface, LanguageFieldInterface};
8
9
/** @var LanguageListInterface $languageModel */
10
/** @var LanguageFieldInterface $language */
11
/** @var array[] $fields */
12
/** @var Model $model */
13
/** @var ActiveForm $form */
14
15
function isActive(LanguageFieldInterface $language)
16
{
17
    return $language->getDefault() == 1 ? 'active' : '';
18
}
19
?>
20
21
<ul class="nav nav-tabs" id="languages">
22
    <?php foreach ($languageModel->getLanguageList() as $language): ?>
23
        <li class="<?php echo isActive($language) ?>">
24
            <a href="#<?php echo $language->getShortName() ?>" data-toggle="tab"><?php echo $language->getName() ?></a>
25
        </li>
26
    <?php endforeach; ?>
27
</ul>
28
29
<div class="tab-content">
30
    <?php foreach ($languageModel->getLanguageList() as $language): ?>
31
        <div class="tab-pane <?php echo isActive($language) ?>" id="<?php echo $language->getShortName() ?>">
32
33 View Code Duplication
            <?php foreach ($fields as $field): ?>
34
35
                <?php if (null === $field || empty($field)) {
36
                    continue;
37
                } ?>
38
39
                <?php echo FieldType::widget(ArrayHelper::merge($field, [
40
                    'model' => $model,
41
                    'form' => $form,
42
                    'language' => $language,
43
                ])) ?>
44
45
            <?php endforeach; ?>
46
47
        </div>
48
    <?php endforeach; ?>
49
</div>
50