|
@@ 38-64 (lines=27) @@
|
| 35 |
|
* @param string $httpClient |
| 36 |
|
* @param ContainerBuilder $container |
| 37 |
|
*/ |
| 38 |
|
private function configureHttpClient($httpClient, ContainerBuilder $container) |
| 39 |
|
{ |
| 40 |
|
if (!class_exists($httpClient)) { |
| 41 |
|
// is a service |
| 42 |
|
$container->setAlias('zenstruck_cache.http_client', $httpClient); |
| 43 |
|
|
| 44 |
|
return; |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
$r = new \ReflectionClass($httpClient); |
| 48 |
|
|
| 49 |
|
if (!$r->implementsInterface('Http\Client\HttpClient')) { |
| 50 |
|
throw new InvalidConfigurationException('HttpClient class must implement "Http\Client\HttpClient".'); |
| 51 |
|
} |
| 52 |
|
|
| 53 |
|
if ($r->isAbstract()) { |
| 54 |
|
throw new InvalidConfigurationException('HttpClient class must not be abstract.'); |
| 55 |
|
} |
| 56 |
|
|
| 57 |
|
if (null !== $r->getConstructor() && 0 !== $r->getConstructor()->getNumberOfRequiredParameters()) { |
| 58 |
|
throw new InvalidConfigurationException('HttpClient class must not have required constructor arguments.'); |
| 59 |
|
} |
| 60 |
|
|
| 61 |
|
$httpClient = new Definition($httpClient); |
| 62 |
|
$httpClient->setPublic(false); |
| 63 |
|
$container->setDefinition('zenstruck_cache.http_client', $httpClient); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
/** |
| 67 |
|
* @param string $messageFactory |
|
@@ 70-96 (lines=27) @@
|
| 67 |
|
* @param string $messageFactory |
| 68 |
|
* @param ContainerBuilder $container |
| 69 |
|
*/ |
| 70 |
|
private function configureMessageFactory($messageFactory, ContainerBuilder $container) |
| 71 |
|
{ |
| 72 |
|
if (!class_exists($messageFactory)) { |
| 73 |
|
// is a service |
| 74 |
|
$container->setAlias('zenstruck_cache.message_factory', $messageFactory); |
| 75 |
|
|
| 76 |
|
return; |
| 77 |
|
} |
| 78 |
|
|
| 79 |
|
$r = new \ReflectionClass($messageFactory); |
| 80 |
|
|
| 81 |
|
if (!$r->implementsInterface('Http\Message\MessageFactory')) { |
| 82 |
|
throw new InvalidConfigurationException('MessageFactory class must implement "Http\Message\MessageFactory".'); |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
if ($r->isAbstract()) { |
| 86 |
|
throw new InvalidConfigurationException('MessageFactory class must not be abstract.'); |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
if (null !== $r->getConstructor() && 0 !== $r->getConstructor()->getNumberOfRequiredParameters()) { |
| 90 |
|
throw new InvalidConfigurationException('MessageFactory class must not have required constructor arguments.'); |
| 91 |
|
} |
| 92 |
|
|
| 93 |
|
$messageFactory = new Definition($messageFactory); |
| 94 |
|
$messageFactory->setPublic(false); |
| 95 |
|
$container->setDefinition('zenstruck_cache.message_factory', $messageFactory); |
| 96 |
|
} |
| 97 |
|
} |
| 98 |
|
|