You are here

class RemoteCalls in Anti Spam by CleanTalk 8.4

Same name in this branch
  1. 8.4 src/lib/Cleantalk/Common/RemoteCalls.php \Cleantalk\Common\RemoteCalls
  2. 8.4 src/lib/Cleantalk/ApbctDrupal/RemoteCalls.php \Cleantalk\ApbctDrupal\RemoteCalls
Same name and namespace in other branches
  1. 9.1.x src/lib/Cleantalk/ApbctDrupal/RemoteCalls.php \Cleantalk\ApbctDrupal\RemoteCalls

Hierarchy

Expanded class hierarchy of RemoteCalls

2 files declare their use of RemoteCalls
BootSubscriber.php in src/EventSubscriber/BootSubscriber.php
CleantalkFuncs.php in src/CleantalkFuncs.php

File

src/lib/Cleantalk/ApbctDrupal/RemoteCalls.php, line 5

Namespace

Cleantalk\ApbctDrupal
View source
class RemoteCalls extends \Cleantalk\Common\RemoteCalls {

  /**
   * SFW update
   *
   * @return string
   */
  public function action__sfw_update() {
    return \Drupal\cleantalk\CleantalkFuncs::apbct_sfw_update($this->api_key);
  }

  /**
   * SFW send logs
   *
   * @return string
   */
  public function action__sfw_send_logs() {
    return \Drupal\cleantalk\CleantalkFuncs::apbct_sfw_send_logs($this->api_key);
  }
  public function action__sfw_update__write_base() {
    return \Drupal\cleantalk\CleantalkFuncs::apbct_sfw_update($this->api_key);
  }

  /**
   * Get available remote calls from the storage.
   *
   * @return array
   */
  protected function getAvailableRcActions() {
    $remote_calls = \Drupal::state()
      ->get('cleantalk_remote_calls');
    if ($remote_calls && !empty($remote_calls)) {
      return empty(array_diff_key($remote_calls, $this->default_rc)) ? $remote_calls : $this->default_rc;
    }
    return $this->default_rc;
  }

  /**
   * Set last call timestamp and save it to the storage.
   *
   * @param string $action
   *
   * @return void
   */
  protected function setLastCall($action) {

    // TODO: Implement setLastCall() method.
    $remote_calls = $this
      ->getAvailableRcActions();
    $remote_calls[$action]['last_call'] = time();
    \Drupal::state()
      ->set('cleantalk_remote_calls', $remote_calls);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RemoteCalls::$api_key protected property
RemoteCalls::$available_rc_actions private property
RemoteCalls::$default_rc protected property
RemoteCalls::$rc_running private property
RemoteCalls::action__sfw_send_logs public function SFW send logs
RemoteCalls::action__sfw_update public function SFW update
RemoteCalls::action__sfw_update__write_base public function
RemoteCalls::check public static function * Checking if the current request is the Remote Call * *
RemoteCalls::COOLDOWN constant
RemoteCalls::getAvailableRcActions protected function Get available remote calls from the storage. Overrides RemoteCalls::getAvailableRcActions
RemoteCalls::perform public function Execute corresponding method of RemoteCalls if exists
RemoteCalls::setLastCall protected function Set last call timestamp and save it to the storage. Overrides RemoteCalls::setLastCall
RemoteCalls::__construct public function