| Conditions | 6 |
| Paths | 5 |
| Total Lines | 33 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 21 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 12 | public static function factory($config = null, array $globalParameters = array()) |
|
| 16 | { |
||
| 17 | 12 | if ($config instanceof Subscription) { |
|
| 18 | |||
| 19 | 12 | $subscription = $config; |
|
| 20 | 12 | if (!isset($subscription['derived_key_salt'])) { |
|
| 21 | 3 | throw new \UnexpectedValueException('Derived key salt not found in subscription'); |
|
| 22 | } |
||
| 23 | 9 | if (!isset($subscription['heartbeat_data']['search_service_colony'])) { |
|
| 24 | 3 | throw new \UnexpectedValueException('Acquia Search hostname not found in subscription'); |
|
| 25 | } |
||
| 26 | 6 | if (!isset($subscription['heartbeat_data']['search_cores'])) { |
|
| 27 | 3 | throw new \UnexpectedValueException('Index data not found in subscription'); |
|
| 28 | } |
||
| 29 | |||
| 30 | 3 | $derivedKey = new DerivedKey($subscription['derived_key_salt'], $subscription->getKey()); |
|
| 31 | |||
| 32 | 3 | $config = array('services' => array()); |
|
| 33 | 3 | foreach ($subscription['heartbeat_data']['search_cores'] as $indexInfo) { |
|
| 34 | |||
| 35 | 3 | $config['services'][$indexInfo['core_id']] = array( |
|
| 36 | 3 | 'class' => 'Acquia\Search\AcquiaSearchClient', |
|
| 37 | 'params' => array( |
||
| 38 | 3 | 'base_url' => 'https://' . $indexInfo['balancer'], |
|
| 39 | 3 | 'index_id' => $indexInfo['core_id'], |
|
| 40 | 3 | 'derived_key' => $derivedKey->generate($indexInfo['core_id']), |
|
| 41 | 3 | ), |
|
| 42 | ); |
||
| 43 | 3 | } |
|
| 44 | 3 | } |
|
| 45 | |||
| 46 | 3 | return parent::factory($config, $globalParameters); |
|
| 47 | } |
||
| 48 | } |
||
| 49 |