|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace App\Application\User\Entity; |
|
6
|
|
|
|
|
7
|
|
|
use Cycle\ORM\ORMInterface; |
|
|
|
|
|
|
8
|
|
|
use Cycle\ORM\Select; |
|
|
|
|
|
|
9
|
|
|
use Cycle\ORM\Transaction; |
|
|
|
|
|
|
10
|
|
|
use Yiisoft\Auth\IdentityInterface; |
|
|
|
|
|
|
11
|
|
|
use Yiisoft\Auth\IdentityRepositoryInterface; |
|
|
|
|
|
|
12
|
|
|
use Yiisoft\Auth\IdentityWithTokenRepositoryInterface; |
|
|
|
|
|
|
13
|
|
|
use Yiisoft\Data\Reader\Sort; |
|
|
|
|
|
|
14
|
|
|
use Yiisoft\Yii\Cycle\Data\Reader\EntityReader; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
final class UserRepository extends Select\Repository implements IdentityWithTokenRepositoryInterface, IdentityRepositoryInterface |
|
|
|
|
|
|
17
|
|
|
{ |
|
18
|
|
|
private ORMInterface $orm; |
|
19
|
|
|
|
|
20
|
|
|
public function __construct(Select $select, ORMInterface $orm) |
|
21
|
|
|
{ |
|
22
|
|
|
$this->orm = $orm; |
|
23
|
|
|
parent::__construct($select); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @psalm-return EntityReader<array-key, User> |
|
28
|
|
|
*/ |
|
29
|
|
|
public function findAllOrderByLogin(): EntityReader |
|
30
|
|
|
{ |
|
31
|
|
|
/** @psalm-var EntityReader<array-key, User> */ |
|
32
|
|
|
return (new EntityReader($this->select())) |
|
33
|
|
|
->withSort( |
|
34
|
|
|
Sort::only(['login'])->withOrderString('login') |
|
35
|
|
|
); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function findIdentity(string $id): ?IdentityInterface |
|
39
|
|
|
{ |
|
40
|
|
|
return $this->findIdentityBy('id', $id); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function findIdentityByToken(string $token, string $type = null): ?IdentityInterface |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->findIdentityBy('token', $token); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function findByLogin(string $login): ?IdentityInterface |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->findIdentityBy('login', $login); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function save(IdentityInterface $user): void |
|
54
|
|
|
{ |
|
55
|
|
|
$transaction = new Transaction($this->orm); |
|
56
|
|
|
$transaction->persist($user); |
|
57
|
|
|
$transaction->run(); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
private function findIdentityBy(string $field, string $value): ?IdentityInterface |
|
61
|
|
|
{ |
|
62
|
|
|
/** |
|
63
|
|
|
* @var $identity IdentityInterface|null |
|
64
|
|
|
*/ |
|
65
|
|
|
return $this->findOne([$field => $value]); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths