|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace JiraRestApi\Provider\Silex1; |
|
4
|
|
|
|
|
5
|
|
|
use GuzzleHttp\Client; |
|
6
|
|
|
use GuzzleHttp\RequestOptions; |
|
7
|
|
|
use JiraRestApi\Configuration\ArrayConfiguration; |
|
8
|
|
|
use Silex\Application; |
|
9
|
|
|
use Silex\ServiceProviderInterface; |
|
10
|
|
|
|
|
11
|
|
|
class JiraRestApiProvider implements ServiceProviderInterface |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @param Application $app |
|
15
|
|
|
*/ |
|
16
|
|
|
public function register(Application $app) |
|
17
|
|
|
{ |
|
18
|
|
|
$app['jira.config'] = []; |
|
19
|
|
|
|
|
20
|
|
View Code Duplication |
$app['jira.rest.transport'] = $app->share(function () use ($app) { |
|
|
|
|
|
|
21
|
|
|
$cfg = $app['jira.rest.configuration']; |
|
22
|
|
|
|
|
23
|
|
|
return new Client([ |
|
24
|
|
|
'base_uri' => $cfg->getJiraHost(), |
|
25
|
|
|
RequestOptions::AUTH => [$cfg->getJiraUser(), $cfg->getJiraPassword()] |
|
26
|
|
|
]); |
|
27
|
|
|
}); |
|
28
|
|
|
|
|
29
|
|
|
$app['jira.rest.configuration'] = $app->share(function() use ($app) { |
|
|
|
|
|
|
30
|
|
|
return new ArrayConfiguration($app['jira.config']); |
|
31
|
|
|
}); |
|
32
|
|
|
|
|
33
|
|
View Code Duplication |
$app['jira.rest.service.builder'] = $app->protect(function($serviceName) use ($app) { |
|
|
|
|
|
|
34
|
|
|
if(class_exists($serviceName)) { |
|
35
|
|
|
return new $serviceName($app['jira.rest.configuration'], $app['jira.rest.transport'], $app['logger']); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
throw new \Exception('Service ' . $serviceName .' not found'); |
|
39
|
|
|
}); |
|
40
|
|
|
|
|
41
|
|
|
$app['jira.rest.issue'] = $app->share(function() use ($app) { |
|
|
|
|
|
|
42
|
|
|
$className = '\JiraRestApi\Issue\IssueService'; |
|
43
|
|
|
return $app['jira.rest.service.builder']($className); |
|
44
|
|
|
}); |
|
45
|
|
|
|
|
46
|
|
|
$app['jira.rest.issuetype'] = $app->share(function() use ($app) { |
|
|
|
|
|
|
47
|
|
|
$className = '\JiraRestApi\Issue\IssueTypeService'; |
|
48
|
|
|
return $app['jira.rest.service.builder']($className); |
|
49
|
|
|
}); |
|
50
|
|
|
|
|
51
|
|
|
$app['jira.rest.project'] = $app->share(function() use ($app) { |
|
|
|
|
|
|
52
|
|
|
$className = '\JiraRestApi\Project\ProjectService'; |
|
53
|
|
|
return $app['jira.rest.service.builder']($className); |
|
54
|
|
|
}); |
|
55
|
|
|
|
|
56
|
|
|
$app['jira.rest.webhook'] = $app->share(function() use ($app) { |
|
|
|
|
|
|
57
|
|
|
$className = '\JiraRestApi\Webhook\WebhookService'; |
|
58
|
|
|
return $app['jira.rest.service.builder']($className); |
|
59
|
|
|
}); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param Application $app |
|
64
|
|
|
*/ |
|
65
|
|
|
public function boot(Application $app) |
|
66
|
|
|
{ |
|
67
|
|
|
} |
|
68
|
|
|
} |
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.