Passed
Push — master ( de9f16...6836c0 )
by Aleksandr
02:35
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
        parent::init();
77
78
        // custom initialization code goes here
79
    }
80
81
    public function getTmpDir($part = null)
82
    {
83
        $dir = \Yii::getAlias($this->tmpDir);
84
        if (!is_dir($dir)) {
85
            FileHelper::createDirectory($dir, 0777, true);
86
        }
87
        return $dir . ($part ? DIRECTORY_SEPARATOR . trim($part, '/\\') : '');
88
    }
89
90
    public function auth($login, $password)
91
    {
92
        /**
93
         * @var $class \yii\web\IdentityInterface
94
         */
95
        $class = \Yii::$app->user->identityClass;
96
        $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

96
        /** @scrutinizer ignore-call */ 
97
        $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...
97
        if ($user && $user->validatePassword($password)) {
98
            return $user;
99
        } else {
100
            return null;
101
        }
102
    }
103
}
104