Skip to content

Commit 228a8a4

Browse files
committed
Add custom trait to prevent name collision in League\OAuth2\Server entity traits.
1 parent 272bec6 commit 228a8a4

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

src/Entity/ClientEntityTrait.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Pdsinterop\Solid\Auth\Entity;
4+
5+
use League\OAuth2\Server\Entities\ClientEntityInterface;
6+
7+
trait ClientEntityTrait
8+
{
9+
/** @var ClientEntityInterface */
10+
private $clientEntity;
11+
12+
public function __construct(ClientEntityInterface $clientEntity)
13+
{
14+
$this->setClientEntity($clientEntity);
15+
}
16+
17+
public function getClientEntity() : ClientEntityInterface
18+
{
19+
if (method_exists($this, 'getClient')) {
20+
$clientEntity = $this->getClient();
21+
} else {
22+
$clientEntity = $this->clientEntity;
23+
}
24+
25+
return $clientEntity;
26+
}
27+
28+
public function setClientEntity(ClientEntityInterface $client) : void
29+
{
30+
if (method_exists($this, 'setClient')) {
31+
$this->setClient($client);
32+
} else {
33+
$this->clientEntity = $client;
34+
}
35+
36+
}
37+
}

0 commit comments

Comments
 (0)