<commit_before><?php

/**
 * Base calls for the CiviCRM communication core
 *
 * @author <NAME>, SYSTOPIA (<EMAIL>)
 */

namespace CMRF\Core;

abstract class Core {

  protected abstract function getConnection($connector_id);

  public abstract function createCall($connector_id, $entity, $action, $parameters, $options = NULL, $callback = NULL);

  public abstract function getCall($call_id);

  public abstract function findCall($options);


  public abstract function getConnectionProfiles();

  public abstract function getDefaultProfile();

  // public function getConnectionProfile($profile_name);



  // public function registerConnector($connector_name, $profile = NULL)

  // public function unregisterConnector($connector_identifier)

  protected abstract function getRegisteredConnectors();

  protected abstract function storeRegisteredConnectors($connectors);

  protected abstract function getSettings();

  protected abstract function storeSettings($settings);



  /**
   * override if certain conditions need to be checked
   */
  public function isReady() {
    return TRUE;
  }


  
  public function executeCall(Call $call) {
    $connection = $this->getConnection($call->getConnectorID());
    return $connection->executeCall($call);
  }

  public function queueCall(Call $call) {
    $connection = $this->getConnection($call->getConnectorID());
    $connection->queueCall($call);
  }

  /**
   * override for a more efficient implementation
   */
  public function getCallStatus($call_id) {
    $call = $this->getCall($call_id);<commit_msg>wip - enabled caching<commit_after><?php

/**
 * Base calls for the CiviCRM communication core
 *
 * @author <NAME>, SYSTOPIA (<EMAIL>)
 */

namespace CMRF\Core;

abstract class Core {

  protected abstract function getConnection($connector_id);

  public abstract function createCall($connector_id, $entity, $action, $parameters, $options = NULL, $callback = NULL);

  public abstract function getCall($call_id);

  public abstract function findCall($options);


  public abstract function getConnectionProfiles();

  public abstract function getDefaultProfile();

  // public function getConnectionProfile($profile_name);



  // public function registerConnector($connector_name, $profile = NULL)

  // public function unregisterConnector($connector_identifier)

  protected abstract function getRegisteredConnectors();

  protected abstract function storeRegisteredConnectors($connectors);

  protected abstract function getSettings();

  protected abstract function storeSettings($settings);



  /**
   * override if certain conditions need to be checked
   */
  public function isReady() {
    return TRUE;
  }


  
  public function executeCall(Call $call) {
    if ($call->getStatus() == Call::STATUS_DONE) {
      // this seems to be cached
      return $call;
    } else {
      $connection = $this->getConnection($call->getConnectorID());
      return $connection->executeCall($call);      
    }
  }

  public function queueCall(Call $call) {
    if ($call->getStatus() == Call::STATUS_DONE) {
      // this seems to be cached
      $this->performCallback($call);
    } else {
      $connection = $this->getConnection($call->getConnectorID());
      $connection->queueCall($call);
    }
  }

  public function performCallback($call) {
    // TODO: implement
    throw new Exception("Callback system not yet implemented", 1);
  }

  /**
   * override for a more efficient implementation
   */
  public function getCallStatus($call_id) {
    $call = $this->getCall($call_id);
{'fraction_non_alphanumeric': 0.11270780501549732, 'fraction_numerical': 0.0002817695125387433, 'mean_word_length': 4.174927113702624, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3553951', 'n_tokens_mistral': 954, 'n_tokens_neox': 912, 'n_words': 263}