| @@ -11,8 +11,12 @@ | ||
| 11 | 11 | /** @var string */ |
| 12 | 12 | private $name; |
| 13 | 13 | /** @var HandlerList */ |
| 14 | 14 | private $handlerList; |
| 15 | + /** @var array */ | |
| 16 | + private $authSchemes; | |
| 17 | + /** @var MetricsBuilder */ | |
| 18 | + private $metricsBuilder; | |
| 15 | 19 | /** |
| 16 | 20 | * Accepts an associative array of command options, including: |
| 17 | 21 | * |
| 18 | 22 | * - @http: (array) Associative array of transfer options. |
| @@ -20,9 +24,9 @@ | ||
| 20 | 24 | * @param string $name Name of the command |
| 21 | 25 | * @param array $args Arguments to pass to the command |
| 22 | 26 | * @param HandlerList $list Handler list |
| 23 | 27 | */ |
| 24 | - public function __construct($name, array $args = [], HandlerList $list = null) | |
| 28 | + public function __construct($name, array $args = [], ?HandlerList $list = null, ?MetricsBuilder $metricsBuilder = null) | |
| 25 | 29 | { |
| 26 | 30 | $this->name = $name; |
| 27 | 31 | $this->data = $args; |
| 28 | 32 | $this->handlerList = $list ?: new HandlerList(); |
| @@ -31,8 +35,9 @@ | ||
| 31 | 35 | } |
| 32 | 36 | if (!isset($this->data['@context'])) { |
| 33 | 37 | $this->data['@context'] = []; |
| 34 | 38 | } |
| 39 | + $this->metricsBuilder = $metricsBuilder ?: new MetricsBuilder(); | |
| 35 | 40 | } |
| 36 | 41 | public function __clone() |
| 37 | 42 | { |
| 38 | 43 | $this->handlerList = clone $this->handlerList; |
| @@ -48,10 +53,54 @@ | ||
| 48 | 53 | public function getHandlerList() |
| 49 | 54 | { |
| 50 | 55 | return $this->handlerList; |
| 51 | 56 | } |
| 57 | + /** | |
| 58 | + * For overriding auth schemes on a per endpoint basis when using | |
| 59 | + * EndpointV2 provider. Intended for internal use only. | |
| 60 | + * | |
| 61 | + * @param array $authSchemes | |
| 62 | + * | |
| 63 | + * @deprecated In favor of using the @context property bag. | |
| 64 | + * Auth Schemes are now accessible via the `signature_version` key | |
| 65 | + * in a Command's context, if applicable. Auth Schemes set using | |
| 66 | + * This method are no longer consumed. | |
| 67 | + * | |
| 68 | + * @internal | |
| 69 | + */ | |
| 70 | + public function setAuthSchemes(array $authSchemes) | |
| 71 | + { | |
| 72 | + \trigger_error(__METHOD__ . ' is deprecated. Auth schemes ' . 'resolved using the service `auth` trait or via endpoint resolution ' . 'are now set in the command `@context` property.`', \E_USER_WARNING); | |
| 73 | + $this->authSchemes = $authSchemes; | |
| 74 | + } | |
| 75 | + /** | |
| 76 | + * Get auth schemes added to command as required | |
| 77 | + * for endpoint resolution | |
| 78 | + * | |
| 79 | + * @returns array | |
| 80 | + * | |
| 81 | + * @deprecated In favor of using the @context property bag. | |
| 82 | + * Auth schemes are now accessible via the `signature_version` key | |
| 83 | + * in a Command's context, if applicable. | |
| 84 | + */ | |
| 85 | + public function getAuthSchemes() | |
| 86 | + { | |
| 87 | + \trigger_error(__METHOD__ . ' is deprecated. Auth schemes ' . 'resolved using the service `auth` trait or via endpoint resolution ' . 'can now be found in the command `@context` property.`', \E_USER_WARNING); | |
| 88 | + return $this->authSchemes ?: []; | |
| 89 | + } | |
| 52 | 90 | /** @deprecated */ |
| 53 | 91 | public function get($name) |
| 54 | 92 | { |
| 55 | 93 | return $this[$name]; |
| 94 | + } | |
| 95 | + /** | |
| 96 | + * Returns the metrics builder instance tied up to this command. | |
| 97 | + * | |
| 98 | + * @internal | |
| 99 | + * | |
| 100 | + * @return MetricsBuilder | |
| 101 | + */ | |
| 102 | + public function getMetricsBuilder() : MetricsBuilder | |
| 103 | + { | |
| 104 | + return $this->metricsBuilder; | |
| 56 | 105 | } |
| 57 | 106 | } |