class TwitterPostCollectorFactory in Social Feed 8
Class TwitterPostCollectorFactory.
@package Drupal\socialfeed\Services
Hierarchy
- class \Drupal\socialfeed\Services\TwitterPostCollectorFactory
Expanded class hierarchy of TwitterPostCollectorFactory
1 file declares its use of TwitterPostCollectorFactory
- TwitterPostBlock.php in src/
Plugin/ Block/ TwitterPostBlock.php
1 string reference to 'TwitterPostCollectorFactory'
1 service uses TwitterPostCollectorFactory
File
- src/
Services/ TwitterPostCollectorFactory.php, line 12
Namespace
Drupal\socialfeed\ServicesView source
class TwitterPostCollectorFactory {
/**
* The default consumer key.
*
* @var string
*/
protected $defaultConsumerKey;
/**
* The default consumer secret.
*
* @var string
*/
protected $defaultConsumerSecret;
/**
* The default access token.
*
* @var string
*/
protected $defaultAccessToken;
/**
* The default access token secret.
*
* @var string
*/
protected $defaultAccessTokenSecret;
/**
* TwitterPostCollectorFactory constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* The config factory.
*/
public function __construct(ConfigFactoryInterface $configFactory) {
$config = $configFactory
->get('socialfeed.twittersettings');
$this->defaultConsumerKey = $config
->get('consumer_key');
$this->defaultConsumerSecret = $config
->get('consumer_secret');
$this->defaultAccessToken = $config
->get('access_token');
$this->defaultAccessTokenSecret = $config
->get('access_token_secret');
}
/**
* Creates a pre-configured instance.
*
* @param string $consumerKey
* The consumer key.
* @param string $consumerSecret
* The consumer secret.
* @param string $accessToken
* The access token.
* @param string $accessTokenSecret
* The access token secret.
*
* @return \Drupal\socialfeed\Services\TwitterPostCollector
* A fully configured instance from TwitterPostCollector.
*
* @throws \Exception
* If the instance cannot be created, such as if the ID is invalid.
*/
public function createInstance(string $consumerKey, string $consumerSecret, string $accessToken, string $accessTokenSecret) {
return new TwitterPostCollector($consumerKey ?: $this->defaultConsumerKey, $consumerSecret ?: $this->defaultConsumerSecret, $accessToken ?: $this->defaultAccessToken, $accessTokenSecret ?: $this->defaultAccessTokenSecret);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TwitterPostCollectorFactory:: |
protected | property | The default access token. | |
TwitterPostCollectorFactory:: |
protected | property | The default access token secret. | |
TwitterPostCollectorFactory:: |
protected | property | The default consumer key. | |
TwitterPostCollectorFactory:: |
protected | property | The default consumer secret. | |
TwitterPostCollectorFactory:: |
public | function | Creates a pre-configured instance. | |
TwitterPostCollectorFactory:: |
public | function | TwitterPostCollectorFactory constructor. |