You are here

public function PullController::endpoint in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 8.3 modules/salesforce_pull/src/Controller/PullController.php \Drupal\salesforce_pull\Controller\PullController::endpoint()
  2. 5.0.x modules/salesforce_pull/src/Controller/PullController.php \Drupal\salesforce_pull\Controller\PullController::endpoint()

Page callback to process push queue for a given mapping.

1 string reference to 'PullController::endpoint'
salesforce_pull.routing.yml in modules/salesforce_pull/salesforce_pull.routing.yml
modules/salesforce_pull/salesforce_pull.routing.yml

File

modules/salesforce_pull/src/Controller/PullController.php, line 130

Class

PullController
Push controller.

Namespace

Drupal\salesforce_pull\Controller

Code

public function endpoint(SalesforceMappingInterface $salesforce_mapping = NULL, $key = NULL, $id = NULL) {

  // If standalone for this mapping is disabled, and global standalone is
  // disabled, then "Access Denied" for this mapping.
  if ($key != $this->stateService
    ->get('system.cron_key')) {
    throw new AccessDeniedHttpException();
  }
  $global_standalone = $this
    ->config('salesforce.settings')
    ->get('standalone');
  if (!$salesforce_mapping && !$global_standalone) {
    throw new AccessDeniedHttpException();
  }
  if ($salesforce_mapping && !$salesforce_mapping
    ->doesPullStandalone() && !$global_standalone) {
    throw new AccessDeniedHttpException();
  }
  if ($id) {
    try {
      $id = new SFID($id);
    } catch (\Exception $e) {
      throw new AccessDeniedHttpException();
    }
  }
  $this
    ->populateQueue($salesforce_mapping, $id);
  $this
    ->processQueue();
  if ($this->request
    ->get('destination')) {
    return new RedirectResponse($this->request
      ->get('destination'));
  }
  return new Response('', 204);
}