| 1 | <?php |
||
| 12 | class CloudApiAuthPlugin implements EventSubscriberInterface |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | protected $username; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | protected $password; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param string $username |
||
| 26 | * @param string $password |
||
| 27 | */ |
||
| 28 | 162 | public function __construct($username, $password) |
|
| 33 | |||
| 34 | /** |
||
| 35 | * @return string |
||
| 36 | */ |
||
| 37 | 3 | public function getUsername() |
|
| 41 | |||
| 42 | /** |
||
| 43 | * @return string |
||
| 44 | */ |
||
| 45 | 3 | public function getPassword() |
|
| 49 | |||
| 50 | /** |
||
| 51 | * {@inheritdoc} |
||
| 52 | */ |
||
| 53 | 159 | public static function getSubscribedEvents() |
|
| 59 | |||
| 60 | /** |
||
| 61 | * Request before-send event handler. |
||
| 62 | * |
||
| 63 | * @param \Guzzle\Common\Event $event |
||
| 64 | */ |
||
| 65 | 144 | public function onRequestBeforeSend(Event $event) |
|
| 69 | |||
| 70 | /** |
||
| 71 | * This method seems silly, but it will be really useful if / when the |
||
| 72 | * authentication scheme becomes more complex. Separating it out from the |
||
| 73 | * event handler allows us to test this code more easily. |
||
| 74 | * |
||
| 75 | * @param \Guzzle\Http\Message\Request $request |
||
| 76 | */ |
||
| 77 | 144 | public function setAuth(Request $request) |
|
| 81 | } |
||
| 82 |