|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Fluxter\SaasProviderBundle\Service; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
|
|
6
|
|
|
use Symfony\Component\HttpFoundation\Session\SessionInterface; |
|
|
|
|
|
|
7
|
|
|
use Fluxter\SaasProviderBundle\Model\SaasClientInterface; |
|
8
|
|
|
|
|
9
|
|
|
class SaasClientService |
|
10
|
|
|
{ |
|
11
|
|
|
/** @var EntityManagerInterface */ |
|
12
|
|
|
private $em; |
|
13
|
|
|
|
|
14
|
|
|
/** @var SessionInterface */ |
|
15
|
|
|
private $session; |
|
16
|
|
|
|
|
17
|
|
|
private $clientEntity; |
|
18
|
|
|
|
|
19
|
|
|
private const SaasClientSessionIndex = "SAASCLIENT"; |
|
20
|
|
|
|
|
21
|
|
|
public function __construct(string $clientEntity, EntityManagerInterface $em, SessionInterface $session) |
|
22
|
|
|
{ |
|
23
|
|
|
$this->em = $em; |
|
24
|
|
|
$this->session = $session; |
|
25
|
|
|
$this->clientEntity = $clientEntity; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function __call($name, $arguments) |
|
29
|
|
|
{ |
|
30
|
|
|
$client = $this->getCurrentCommunity(); |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
$method = "get$name"; |
|
33
|
|
|
if (method_exists($client, $method)) { |
|
34
|
|
|
return $client->$method(); |
|
35
|
|
|
} |
|
36
|
|
|
$method = "is$name"; |
|
37
|
|
|
if (method_exists($client, $method)) { |
|
38
|
|
|
return $client->$method(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
throw new \Exception("Unknown SaaS-Client function / variable: {$name}!"); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function createClient() |
|
45
|
|
|
{ } |
|
46
|
|
|
|
|
47
|
|
|
public function getCurrent() |
|
48
|
|
|
{ |
|
49
|
|
|
if (!$this->session->has(self::SaasClientSessionIndex)) { |
|
50
|
|
|
throw new \Exception("SAAS-CLIENT SESSION VARIABLE NOT SPECIFIED"); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
// Todo Entity name from configuration |
|
54
|
|
|
$repo = $this->em->getRepository($this->clientEntity); |
|
55
|
|
|
|
|
56
|
|
|
/** @var SaasClientInterface $client */ |
|
57
|
|
|
$client = $repo->findOneById($this->session->get(self::SaasClientSessionIndex)); |
|
58
|
|
|
if ($client == null) { |
|
59
|
|
|
throw new \Exception("SAAS-CLIENT NOT FOUND!"); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
return $client; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
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