Passed
Push — master ( 2eb3e0...27f2a2 )
by Aleksandr
01:50
created

ExchangeModule.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace carono\exchange1c;
4
5
use yii\helpers\FileHelper;
6
7
/**
8
 * exchange module definition class
9
 */
10
class ExchangeModule extends \yii\base\Module
11
{
12
    /**
13
     * @inheritdoc
14
     */
15
    public $controllerNamespace = 'carono\exchange1c\controllers';
16
    /**
17
     * @var \carono\exchange1c\interfaces\ProductInterface
18
     */
19
    public $productClass;
20
    /**
21
     * @var \carono\exchange1c\interfaces\OfferInterface
22
     */
23
    public $offerClass;
24
    /**
25
     * @var \carono\exchange1c\interfaces\DocumentInterface
26
     */
27
    public $documentClass;
28
    /**
29
     * @var \carono\exchange1c\interfaces\GroupInterface
30
     */
31
    public $groupClass;
32
    /**
33
     * @var \carono\exchange1c\interfaces\PartnerInterface
34
     */
35
    public $partnerClass;
36
    /**
37
     * @var \carono\exchange1c\interfaces\WarehouseInterface
38
     */
39
    public $warehouseClass;
40
41
    /**
42
     * Обмен документами
43
     *
44
     * @var bool
45
     */
46
    public $exchangeDocuments = false;
47
    /**
48
     * Режим отладки - сохраняем xml файлы в runtime
49
     *
50
     * @var bool
51
     */
52
    public $debug = false;
53
    /**
54
     * При обмене используем архиватор, если расширения нет, то зачение не учитывается
55
     *
56
     * @var bool
57
     */
58
    public $useZip = true;
59
    public $tmpDir = '@runtime/1c_exchange';
60
    /**
61
     * При сохранении товара, используем валидацию или нет
62
     *
63
     * @var bool
64
     */
65
    public $validateModelOnSave = false;
66
    public $timeLimit = 1800;
67
    public $memoryLimit = null;
68
    public $bootstrapUrlRule = true;
69
    public $auth;
70
71
    /**
72
     * @inheritdoc
73
     */
74
    public function init()
75
    {
76
        if (!isset(\Yii::$app->i18n->translations['models'])) {
77
            \Yii::$app->i18n->translations['models'] = [
78
                'class' => 'yii\i18n\PhpMessageSource',
79
                'basePath' => '@app/messages',
80
                'sourceLanguage' => 'en',
81
            ];
82
        }
83
        parent::init();
84
    }
85
86
    public function getTmpDir($part = null)
87
    {
88
        $dir = \Yii::getAlias($this->tmpDir);
89
        if (!is_dir($dir)) {
90
            FileHelper::createDirectory($dir, 0777, true);
91
        }
92
        return $dir . ($part ? DIRECTORY_SEPARATOR . trim($part, '/\\') : '');
93
    }
94
95
    public function auth($login, $password)
96
    {
97
        /**
98
         * @var $class \yii\web\IdentityInterface
99
         */
100
        $class = \Yii::$app->user->identityClass;
101
        $user = $class::findByUsername($login);
0 ignored issues
show
The method findByUsername() does not exist on yii\web\IdentityInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

101
        /** @scrutinizer ignore-call */ 
102
        $user = $class::findByUsername($login);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
102
        if ($user && $user->validatePassword($password)) {
103
            return $user;
104
        } else {
105
            return null;
106
        }
107
    }
108
}
109