1 | <?php |
||||||
2 | /** |
||||||
3 | * @package php-tmdb\laravel |
||||||
4 | * @author Mark Redeman <[email protected]> |
||||||
5 | * @copyright (c) 2014, Mark Redeman |
||||||
6 | */ |
||||||
7 | namespace Tmdb\Laravel; |
||||||
8 | |||||||
9 | use Illuminate\Support\ServiceProvider; |
||||||
10 | use Tmdb\Event\BeforeRequestEvent; |
||||||
11 | use Tmdb\Event\Listener\Request\AcceptJsonRequestListener; |
||||||
12 | use Tmdb\Event\Listener\Request\ApiTokenRequestListener; |
||||||
13 | use Tmdb\Event\Listener\Request\ContentTypeJsonRequestListener; |
||||||
14 | use Tmdb\Event\Listener\Request\UserAgentRequestListener; |
||||||
15 | use Tmdb\Event\Listener\RequestListener; |
||||||
16 | use Tmdb\Event\RequestEvent; |
||||||
17 | use Tmdb\Laravel\TmdbServiceProviderLaravel; |
||||||
18 | use Tmdb\Client; |
||||||
19 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
||||||
20 | use Symfony\Component\EventDispatcher\EventDispatcher; |
||||||
21 | use Tmdb\Laravel\Adapters\EventDispatcherAdapter; |
||||||
22 | use Tmdb\Model\Configuration; |
||||||
23 | use Tmdb\Repository\ConfigurationRepository; |
||||||
24 | use Tmdb\Token\Api\ApiToken; |
||||||
25 | |||||||
26 | class TmdbServiceProvider extends ServiceProvider |
||||||
27 | { |
||||||
28 | /** |
||||||
29 | * Indicates if loading of the provider is deferred. |
||||||
30 | * |
||||||
31 | * @var bool |
||||||
32 | */ |
||||||
33 | protected $defer = false; |
||||||
34 | |||||||
35 | /** |
||||||
36 | * Actual provider |
||||||
37 | * |
||||||
38 | * @var \Illuminate\Support\ServiceProvider |
||||||
39 | */ |
||||||
40 | protected $provider; |
||||||
41 | |||||||
42 | /** |
||||||
43 | * Construct the TMDB service provider |
||||||
44 | */ |
||||||
45 | public function __construct() |
||||||
46 | { |
||||||
47 | // Call the parent constructor with all provided arguments |
||||||
48 | $arguments = func_get_args(); |
||||||
49 | call_user_func_array( |
||||||
50 | [$this, 'parent::' . __FUNCTION__], |
||||||
51 | $arguments |
||||||
52 | ); |
||||||
53 | |||||||
54 | $this->registerProvider(); |
||||||
55 | } |
||||||
56 | |||||||
57 | /** |
||||||
58 | * Bootstrap the application events. |
||||||
59 | * |
||||||
60 | * @return void |
||||||
61 | */ |
||||||
62 | public function boot() |
||||||
63 | { |
||||||
64 | return $this->provider->boot(); |
||||||
0 ignored issues
–
show
|
|||||||
65 | } |
||||||
66 | |||||||
67 | /** |
||||||
68 | * Register the service provider. |
||||||
69 | * |
||||||
70 | * @return void |
||||||
71 | */ |
||||||
72 | public function register() |
||||||
73 | { |
||||||
74 | // Configure any bindings that are version dependent |
||||||
75 | $this->provider->register(); |
||||||
76 | |||||||
77 | // Let the IoC container be able to make a Symfony event dispatcher |
||||||
78 | $this->app->bind( |
||||||
79 | EventDispatcherInterface::class, |
||||||
80 | EventDispatcher::class |
||||||
81 | ); |
||||||
82 | |||||||
83 | // Setup default configurations for the Tmdb Client |
||||||
84 | $this->app->singleton(Client::class, function() { |
||||||
85 | $config = $this->provider->config(); |
||||||
0 ignored issues
–
show
The method
config() does not exist on Illuminate\Support\ServiceProvider . It seems like you code against a sub-type of Illuminate\Support\ServiceProvider such as Tmdb\Laravel\TmdbServiceProviderLaravel .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
86 | |||||||
87 | $ed = $this->app->make(EventDispatcherAdapter::class); |
||||||
88 | $client = new Client( |
||||||
89 | [ |
||||||
90 | 'api_token' => new ApiToken($config['api_key']), |
||||||
91 | 'event_dispatcher' => |
||||||
92 | [ |
||||||
93 | 'adapter' => $ed |
||||||
94 | ], |
||||||
95 | ] |
||||||
96 | ); |
||||||
97 | /** |
||||||
98 | * Required event listeners and events to be registered with the PSR-14 Event Dispatcher. |
||||||
99 | */ |
||||||
100 | $requestListener = new RequestListener($client->getHttpClient(), $ed); |
||||||
101 | $ed->addListener(RequestEvent::class, $requestListener); |
||||||
102 | |||||||
103 | $apiTokenListener = new ApiTokenRequestListener($client->getToken()); |
||||||
104 | $ed->addListener(BeforeRequestEvent::class, $apiTokenListener); |
||||||
105 | |||||||
106 | $acceptJsonListener = new AcceptJsonRequestListener(); |
||||||
107 | $ed->addListener(BeforeRequestEvent::class, $acceptJsonListener); |
||||||
108 | |||||||
109 | $jsonContentTypeListener = new ContentTypeJsonRequestListener(); |
||||||
110 | $ed->addListener(BeforeRequestEvent::class, $jsonContentTypeListener); |
||||||
111 | |||||||
112 | $userAgentListener = new UserAgentRequestListener(); |
||||||
113 | $ed->addListener(BeforeRequestEvent::class, $userAgentListener); |
||||||
114 | return $client; |
||||||
115 | }); |
||||||
116 | } |
||||||
117 | |||||||
118 | /** |
||||||
119 | * Register the ServiceProvider |
||||||
120 | */ |
||||||
121 | private function registerProvider() |
||||||
122 | { |
||||||
123 | $app = $this->app; |
||||||
124 | $this->provider = new TmdbServiceProviderLaravel($app); |
||||||
125 | } |
||||||
126 | |||||||
127 | /** |
||||||
128 | * Get the services provided by the provider. |
||||||
129 | * |
||||||
130 | * @return array |
||||||
131 | */ |
||||||
132 | public function provides() |
||||||
133 | { |
||||||
134 | return array('tmdb'); |
||||||
135 | } |
||||||
136 | } |
||||||
137 |
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.