Bristol SU Support Package
ModuleInstanceServiceRepository.php
Go to the documentation of this file.
1 <?php
2 
4 
9 
13 class ModuleInstanceServiceRepository implements ModuleInstanceServiceRepositoryContract
14 {
15 
25  public function getConnectorForService(string $service, int $moduleInstanceId): Connector
26  {
27  try {
28  $moduleInstanceService = ModuleInstanceService::where('service', $service)->where('module_instance_id', $moduleInstanceId)
29  ->firstOrFail();
30  } catch (ModelNotFoundException $e) {
31  throw new NoConnectionAvailable(sprintf('No connection has been found for %s', $service));
32  }
33  return app(ConnectorFactory::class)->createFromConnection($moduleInstanceService->connection);
34  }
35 
41  public function all()
42  {
43  return ModuleInstanceService::all();
44  }
45 }