You are here

class ServicesClientEventResult in Services Client 7.2

Class for handling event operation results.

Hierarchy

Expanded class hierarchy of ServicesClientEventResult

2 string references to 'ServicesClientEventResult'
drush_services_client_process_queue in ./services_client.drush.inc
Process queued sync jobs
ServicesClientWebTestCase::testServicesClientProcessing in tests/services_client.test

File

include/plugin.inc, line 272
Base plugin definitions. All other plugins should be extended from this set of plugins.

View source
class ServicesClientEventResult {

  /**
   * Initialized event handler.
   *
   * @var EventHandler
   */
  protected $handler;

  /**
   * Entity id.
   *
   * @var int
   */
  protected $entity_id;

  /**
   * Event data object.
   *
   * @var stdClass
   */
  public $event;

  /**
   * Entity which was processed in event.
   *
   * @var stdClass
   */
  public $entity;

  /**
   * Entity type.
   *
   * @var string
   */
  public $entity_type;

  /**
   * Mapped object if exists.
   *
   * @var stdClass
   */
  public $object;

  /**
   * Request sent to remote site.
   *
   * @var ServicesClientConnectionHttpRequest
   */
  public $request;

  /**
   * Response retrieved from remote site.
   *
   * @var ServicesClientConnectionResponse
   */
  public $response;

  /**
   * If failed error message from exception.
   *
   * @var string
   */
  public $error_message;

  /**
   * If failed error code from exception.
   *
   * @var int
   */
  public $error_code;

  /**
   * Error type.
   *
   * @var ServicesClientErrorType const
   */
  public $error_type;

  /**
   * Retrieve entity id.
   *
   * @return int
   */
  public function getEntityId() {
    if (empty($this->entity_id)) {
      list($this->entity_id) = entity_extract_ids($this->entity_type, $this->entity);
    }
    return $this->entity_id;
  }

  /**
   * Retrieve event handler.
   *
   * @return EventHandler
   */
  public function getHandler() {

    // Lazy load handler.
    if (empty($this->handler)) {
      $this->handler = $this->event
        ->getHandler();
    }
    return $this->handler;
  }

  /**
   * Set current handler.
   *
   * @param EventHandler $handler
   *   Event handler.
   */
  public function setHandler(EventHandler $handler) {
    $this->handler = $handler;
    return $this;
  }

  /**
   * Retry event.
   *
   * @return ServicesClientEventResult
   *   Result of new operation.
   */
  public function retry() {
    return $this
      ->getHandler()
      ->execute();
  }

  /**
   * Returns if event was successful.
   *
   * @return bool
   *   TRUE if successful.
   */
  public function success() {
    return empty($this->error_code) && empty($this->error_type);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ServicesClientEventResult::$entity public property Entity which was processed in event.
ServicesClientEventResult::$entity_id protected property Entity id.
ServicesClientEventResult::$entity_type public property Entity type.
ServicesClientEventResult::$error_code public property If failed error code from exception.
ServicesClientEventResult::$error_message public property If failed error message from exception.
ServicesClientEventResult::$error_type public property Error type.
ServicesClientEventResult::$event public property Event data object.
ServicesClientEventResult::$handler protected property Initialized event handler.
ServicesClientEventResult::$object public property Mapped object if exists.
ServicesClientEventResult::$request public property Request sent to remote site.
ServicesClientEventResult::$response public property Response retrieved from remote site.
ServicesClientEventResult::getEntityId public function Retrieve entity id.
ServicesClientEventResult::getHandler public function Retrieve event handler.
ServicesClientEventResult::retry public function Retry event.
ServicesClientEventResult::setHandler public function Set current handler.
ServicesClientEventResult::success public function Returns if event was successful.