Skip to content
Snippets Groups Projects
Commit e72ca03b authored by Ritvik Tak's avatar Ritvik Tak Committed by Aaron Bauman
Browse files

Issue #3222661 by Ken Patolia, ritviktak, AaronBauman: Coding Standard update

parent 18c5c3b3
No related branches found
No related tags found
No related merge requests found
Pipeline #57425 failed
......@@ -26,6 +26,60 @@ class SalesforceExampleSubscriber implements EventSubscriberInterface {
use StringTranslationTrait;
/**
* Logger.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* The Salesforce REST client.
*
* @var \Drupal\salesforce\Rest\RestClientInterface
*/
protected $client;
/**
* Create a new Salesforce object.
*
* @param \Psr\Log\LoggerInterface $logger
* The logger.
* @param \Drupal\salesforce\Rest\RestClientInterface $salesforce_client
* The factory for configuration objects.
*/
public function __construct(LoggerInterface $logger, RestClientInterface $salesforce_client) {
$this->logger = $logger;
$this->client = $salesforce_client;
}
/**
* Logger.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* The Salesforce REST client.
*
* @var \Drupal\salesforce\Rest\RestClientInterface
*/
protected $client;
/**
* Create a new Salesforce object.
*
* @param \Psr\Log\LoggerInterface $logger
* The logger.
* @param \Drupal\salesforce\Rest\RestClientInterface $salesforce_client
* The factory for configuration objects.
*/
public function __construct(LoggerInterface $logger, RestClientInterface $salesforce_client) {
$this->logger = $logger;
$this->client = $salesforce_client;
}
/**
* SalesforcePushAllowedEvent callback.
*
......@@ -81,7 +135,7 @@ class SalesforceExampleSubscriber implements EventSubscriberInterface {
// Do Y.
break;
}
\Drupal::messenger()->addStatus('push success example subscriber!: ' . $event->getMappedObject()->sfid());
$this->messenger->addStatus('push success example subscriber!: ' . $event->getMappedObject()->sfid());
}
/**
......@@ -91,7 +145,7 @@ class SalesforceExampleSubscriber implements EventSubscriberInterface {
* The event.
*/
public function pushFail(SalesforcePushOpEvent $event) {
\Drupal::messenger()->addStatus('push fail example: ' . $event->getMappedObject()->id());
$this->messenger->addStatus('push fail example: ' . $event->getMappedObject()->id());
}
/**
......@@ -133,7 +187,7 @@ class SalesforceExampleSubscriber implements EventSubscriberInterface {
// Attachment data, if given.
$account = $event->getEntity();
$sf_data = $event->getMappedObject()->getSalesforceRecord();
$client = \Drupal::service('salesforce.client');
$client = $this->client;
// Fetch the attachment URL from raw sf data.
$attachments = [];
try {
......@@ -158,7 +212,7 @@ class SalesforceExampleSubscriber implements EventSubscriberInterface {
}
catch (\Exception $e) {
// Unable to fetch file data from SF.
\Drupal::logger('db')->error($this->t('failed to fetch attachment for user @user', ['@user' => $account->id()]));
$this->logger('db')->error($this->t('failed to fetch attachment for user @user', ['@user' => $account->id()]));
return;
}
......@@ -171,7 +225,7 @@ class SalesforceExampleSubscriber implements EventSubscriberInterface {
$account->user_picture->target_id = $file->id();
}
else {
\Drupal::logger('db')->error('failed to save profile pic for user ' . $account->id());
$this->logger('db')->error('failed to save profile pic for user ' . $account->id());
}
break;
......
......@@ -26,6 +26,13 @@ class SalesforceLoggerSubscriber implements EventSubscriberInterface {
*/
protected $logger;
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Create a new Salesforce Logger Subscriber.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment