Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • CurlAuthPlugin
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: namespace Guzzle\Plugin\CurlAuth;
 4: 
 5: use Guzzle\Common\Event;
 6: use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 7: 
 8: /**
 9:  * Adds specified curl auth to all requests sent from a client. Defaults to CURLAUTH_BASIC if none supplied.
10:  */
11: class CurlAuthPlugin implements EventSubscriberInterface
12: {
13:     private $username;
14:     private $password;
15:     private $scheme;
16: 
17:     /**
18:      * Constructor
19:      *
20:      * @param string $username HTTP basic auth username
21:      * @param string $password Password
22:      * @param int    $scheme   Curl auth scheme
23:      */
24:     public function __construct($username, $password, $scheme=CURLAUTH_BASIC)
25:     {
26:         $this->username = $username;
27:         $this->password = $password;
28:         $this->scheme = $scheme;
29:     }
30: 
31:     /**
32:      * {@inheritdoc}
33:      */
34:     public static function getSubscribedEvents()
35:     {
36:         return array('client.create_request' => array('onRequestCreate', 255));
37:     }
38: 
39:     /**
40:      * Add basic auth
41:      *
42:      * @param Event $event
43:      */
44:     public function onRequestCreate(Event $event)
45:     {
46:         $event['request']->setAuth($this->username, $this->password, $this->scheme);
47:     }
48: }
49: 
php-coveralls API documentation generated by ApiGen 2.8.0