You are here

class EntityDeleteHandler in Services Client 7.2

General entity delete handler.

Hierarchy

Expanded class hierarchy of EntityDeleteHandler

2 string references to 'EntityDeleteHandler'
services_client_migrate_hook in ./services_client.legacy.inc
Migrate old hook with mapping to new system.
services_client_services_client_event_handler in ./services_client.plugins.inc
List availalable event handler plugins.

File

include/event.inc, line 1042

View source
class EntityDeleteHandler extends EventHandler {

  /**
   * Execute event and send event to remove endpoint.
   *
   * @return ServicesClientEventResult
   */
  public function execute() {

    // Create action result.
    $result = new ServicesClientEventResult();
    $result
      ->setHandler($this);
    $result->event = $this
      ->getEvent();
    $result->object = NULL;
    $result->entity = $this
      ->getEntity();
    $result->entity_type = $result->event->entity_type;

    // Allow other modules to react on before request.
    module_invoke_all('services_client_before_request', $this, NULL);
    $this
      ->log(ServicesClientLogLevel::INFO, "DELETING; connection : @connection, event : @event, entity_type : @entity_type, entity_id : @entity_id, uuid : @uuid", array(
      '@event' => $this->event->name,
      '@connection' => $this
        ->getConnectionId(),
      '@entity_type' => $this->event->entity_type,
      '@entity_id' => $this
        ->getEntityId(),
      '@uuid' => $this
        ->getEntity()->uuid,
    ));
    try {
      $result->response = $this
        ->doSync(NULL);
      $result->request = $this
        ->getConnection()
        ->getRequest();
    } catch (ServicesClientConnectionResponseException $e) {
      $e
        ->log();
      $result->error_message = $e
        ->getServicesMessage();
      $result->error_code = $e
        ->getErrorCode();
      $result->request = $e->request;

      // Determien what error type, by default we assume remote server failed.
      $error_type = ServicesClientErrorType::REMOTE_SERVER;

      // Logic errors that came from remote site, like can't login
      if ($e
        ->getErrorCode() >= 400 && $e
        ->getErrorCode() < 500) {
        $error_type = ServicesClientErrorType::REMOTE_LOGIC;
      }
      elseif ($e
        ->getErrorCode() < 100) {
        $error_type = ServicesClientErrorType::NETWORK;
      }

      // Set error type
      $result->error_type = $error_type;
    } catch (Exception $e) {
      $result->error_message = $e
        ->getMessage();
      $result->error_type = ServicesClientErrorType::UNKNOWN;
    }
    $this
      ->logErrorResult($result);
    $this
      ->afterSync(NULL, $result);

    // Allow other modules to react on after request.
    module_invoke_all('services_client_after_request', $this, NULL, $result);
    return $result;
  }

  /**
   * Execute sync action.
   */
  protected function doSync($object) {
    $id = $this
      ->getRemoteEntityId();
    if (!empty($id)) {
      $this
        ->getConnection()
        ->delete($this->config['resource'], $id);
      return $this
        ->getConnection()
        ->getResponse();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityDeleteHandler::doSync protected function Execute sync action. Overrides EventHandler::doSync
EntityDeleteHandler::execute public function Execute event and send event to remove endpoint. Overrides EventHandler::execute
EventHandler::$connection protected property Holds connection to remote server.
EventHandler::$entity protected property Processed drupal entity in event.
EventHandler::$plugin_instances protected property Initialized plugin classes.
EventHandler::$tags protected property Stores tags assigned to event.
EventHandler::addPlugin public function Add configuration plugin.
EventHandler::addTag public function Add event tag.
EventHandler::afterSync protected function Allow plugin to react on before sync event.
EventHandler::beforeSync protected function Allow plugin to react on before sync event. 2
EventHandler::breakEditLock public function Break any edit lock for current event.
EventHandler::clearObjectCache public function Clear current object cache.
EventHandler::configForm public function Configuration form. Overrides ServicesClientPlugin::configForm 1
EventHandler::configFormSubmit public function Submit handler; Store plugin configuration. Overrides ServicesClientPlugin::configFormSubmit 2
EventHandler::debugObject protected function Retrieve printed version of any variable. Should be used for logging.
EventHandler::enqueue public function Enqueue item if should be queue.
EventHandler::enqueueEntity protected function Put current entity to queue.
EventHandler::generateUuid protected function Generates a UUID v4 using PHP code.
EventHandler::getBaseUrl public function Retrieve UI base url for event.
EventHandler::getConnection protected function Retrieves event connection to remote site.
EventHandler::getConnectionId protected function Retrieve remote connection id.
EventHandler::getControlData protected function Retrieve controll data for current entity.
EventHandler::getDefaultConfiguration protected function Retrieve default event configuration. 1
EventHandler::getEditLock public function Retrieve edit lock if exists (other user is editing same event).
EventHandler::getEntity public function Retrieve current event entity.
EventHandler::getEntityId public function Retrieve entity ID.
EventHandler::getEvent public function Retrieve event definition.
EventHandler::getObjectCache public function Retrieve object cached version of event.
EventHandler::getObjectCacheOrCache public function Retrieve current object from cache. If not currently in object cache adds object to object cache.
EventHandler::getPlugin public function Retrieve existing plugin.
EventHandler::getPluginInstance protected function Retrieve plugin instance by name and configuration.
EventHandler::getRemoteEntityId public function Retrieve remote entity ID. 1
EventHandler::getRemoteIdByUUID protected function Load remote ID by UUID based on remote UUID configuration.
EventHandler::getUrl public function Get path prefixed with event specific URL.
EventHandler::hasTag public function Check if event has specific tag.
EventHandler::isAutoTriggered public function Determine weather event should be fired automatically on drupal object action like node_save or node_delete.
EventHandler::isChanged public function Determine weather object has been changed by editing configuration and not which isn't stored in permanent storage.
EventHandler::isMatching public function Determine wheather entity is matching event conditions.
EventHandler::log protected function Log messages to Drupal watchdog.
EventHandler::logErrorResult protected function Log error result from services client operation.
EventHandler::objectCached public function Retrieve instance of object initialized with object cache.
EventHandler::removePlugin public function Remove existing plugin from configuration. This does is not saved to DB until save() method is called.
EventHandler::removeTag public function Remove tag from event.
EventHandler::save public function Save current event configuration to database.
EventHandler::setConnection public function Set new connection to remote site.
EventHandler::setEntity public function Set entity for current event.
EventHandler::setObjectCache public function Store current object state to object cache.
EventHandler::setPluginConfig public function Update plugin configuration. This does is not saved to DB until save() method is called.
EventHandler::skipAutosync public function Return TRUE if this entity shouldn't be send automatically to all connections.
EventHandler::__construct public function Constructor. Overrides ServicesClientPlugin::__construct
ServicesClientPlugin::$config protected property Plugin specific configuration
ServicesClientPlugin::$event protected property Event definition
ServicesClientPlugin::configFormValidate public function Validate configuration form. Overrides ServicesClientConfigurableInterface::configFormValidate 1
ServicesClientPlugin::getConfiguration public function Retrieve current plugin configuration. Overrides ServicesClientConfigurableInterface::getConfiguration
ServicesClientPlugin::setConfiguration public function Set configuration of plugin. Overrides ServicesClientConfigurableInterface::setConfiguration