You are here

public function SalesforcePullCommands::pullReset in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 modules/salesforce_pull/src/Commands/SalesforcePullCommands.php \Drupal\salesforce_pull\Commands\SalesforcePullCommands::pullReset()
  2. 8.3 modules/salesforce_pull/src/Commands/SalesforcePullCommands.php \Drupal\salesforce_pull\Commands\SalesforcePullCommands::pullReset()

Reset pull timestamps for one or all Salesforce Mappings.

@option delete Reset delete date timestamp (instead of pull date timestamp) @usage drush sf-pull-reset Reset pull timestamps for all mappings. @usage drush sf-pull-reset foo Reset pull timestamps for mapping "foo" @usage drush sf-pull-reset --delete Reset "delete" timestamps for all mappings @usage drush sf-pull-reset foo --delete Reset "delete" timestamp for mapping "foo"

@command salesforce_pull:pull-reset @aliases sf-pull-reset,salesforce_pull:reset

Parameters

string $name: Mapping id.

array $options: An associative array of options whose values come from cli, aliases, config, etc.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

File

modules/salesforce_pull/src/Commands/SalesforcePullCommands.php, line 337

Class

SalesforcePullCommands
A Drush commandfile.

Namespace

Drupal\salesforce_pull\Commands

Code

public function pullReset($name, array $options = [
  'delete' => NULL,
]) {
  $mappings = $this
    ->getPullMappingsFromName($name);
  foreach ($mappings as $mapping) {
    if ($options['delete']) {
      $mapping
        ->setLastDeleteTime(NULL);
    }
    else {
      $mapping
        ->setLastPullTime(NULL);
    }
    \Drupal::entityTypeManager()
      ->getStorage('salesforce_mapped_object')
      ->setForcePull($mapping);
    $this
      ->logger()
      ->info(dt('Pull timestamp reset for !name', [
      '!name' => $name,
    ]));
  }
}