class SendUsageData in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/QueueWorker/SendUsageData.php \Drupal\social_lets_connect_usage\Plugin\QueueWorker\SendUsageData
- 8.5 modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/QueueWorker/SendUsageData.php \Drupal\social_lets_connect_usage\Plugin\QueueWorker\SendUsageData
- 8.6 modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/QueueWorker/SendUsageData.php \Drupal\social_lets_connect_usage\Plugin\QueueWorker\SendUsageData
- 8.7 modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/QueueWorker/SendUsageData.php \Drupal\social_lets_connect_usage\Plugin\QueueWorker\SendUsageData
- 10.3.x modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/QueueWorker/SendUsageData.php \Drupal\social_lets_connect_usage\Plugin\QueueWorker\SendUsageData
- 10.0.x modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/QueueWorker/SendUsageData.php \Drupal\social_lets_connect_usage\Plugin\QueueWorker\SendUsageData
- 10.1.x modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/QueueWorker/SendUsageData.php \Drupal\social_lets_connect_usage\Plugin\QueueWorker\SendUsageData
- 10.2.x modules/custom/social_lets_connect/modules/social_lets_connect_usage/src/Plugin/QueueWorker/SendUsageData.php \Drupal\social_lets_connect_usage\Plugin\QueueWorker\SendUsageData
Send usage data.
@QueueWorker( id = "send_usage_data", title = @Translation("Send usage data."), cron = {"time" = 300} )
This QueueWorker is responsible for sending usage data.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
- class \Drupal\social_lets_connect_usage\Plugin\QueueWorker\SendUsageData implements ContainerFactoryPluginInterface uses StringTranslationTrait
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of SendUsageData
File
- modules/
custom/ social_lets_connect/ modules/ social_lets_connect_usage/ src/ Plugin/ QueueWorker/ SendUsageData.php, line 25
Namespace
Drupal\social_lets_connect_usage\Plugin\QueueWorkerView source
class SendUsageData extends QueueWorkerBase implements ContainerFactoryPluginInterface {
use StringTranslationTrait;
/**
* The config.
*
* @var \Drupal\Core\Config\ConfigFactory
*/
public $config;
/**
* The http client.
*
* @var \GuzzleHttp\Client
*/
public $client;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactory $config, Client $client) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->config = $config;
$this->client = $client;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('config.factory'), $container
->get('http_client'));
}
/**
* Will process a queue item.
*
* $send_data['site_key'] = $site_key;
* $send_data['send_info'] = [
* 'last_send' => $last_send,
* 'times_send' => $times_send,
* 'current_time' => $current_time,
* ];
* $send_data['usage_data'] = array $usage_data;
*/
public function processItem($data) {
$config = $this->config
->get('social_lets_connect_usage.settings');
$usage_data_url = $config
->get('url');
try {
$response = $this->client
->post($usage_data_url, [
'json' => $data,
]);
} catch (RequestException $e) {
return FALSE;
}
return Json::decode($response
->getBody()
->getContents());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
SendUsageData:: |
public | property | The http client. | |
SendUsageData:: |
public | property | The config. | |
SendUsageData:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
SendUsageData:: |
public | function |
Will process a queue item. Overrides QueueWorkerInterface:: |
|
SendUsageData:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |