Slate Documentation

Building a Connector

Building a Connector

Overview

Connectors are PHP classes that implement the Slate\Connectors\IConnector.

Create the connector class

Interfaces

Traits

Synchronization

Guidelines for building a synchronizer

  • The synchronize method should handle bringing the remote system into mutual harmony, and should determine the appropriate pull and/or push operations based on the connector’s static configuration and the configuration supplied via the $Job.
  • When $pretend == true, the synchronizer should produce a log and results output as similar as possible to when $pretend == false, but make no changes to the state of either the local or remote system.
  • After every change, write an entry to $Job->log.
  • Avoid writing messages to the log about things that may or may not happen next if it can be more accurately described after the result is known.
  • The synchronize method should be idempotent — running it multiple times with the same configuration and input database should result in no additional changes to either the local or remote systems’ state, other than updating the status of the current job.
  • To the furthest extent possible without risking making inaccurate changes, the synchronize method should be able to bring records to the same level of consistency whether they were created by the connector or existing in either system before integration started.

Logging

The $Job->log() method accepts $level as its second parameter, use the Psr\Log\LogLevel constants documented in PSR-3.

Follow these guidelines for which log levels to use when logging arbitrary messages or custom events (the higher-level log methods logRecordDelta, logInvalidRecord, and logException will choose an appropriate level automatically):

  • LogLevel::EMERGENCY - synchronization cannot begin because local system is unusable
  • LogLevel::ALERT - synchronization cannot begin because local system is not configured correctly
  • LogLevel::CRITICAL - synchronization cannot begin because remote system is unreachable/unusable
  • LogLevel::ERROR - a record must be skipped because it is malformed
  • LogLevel::WARNING - a record cannot be completely synchronized
  • LogLevel::NOTICE - a change is or will be made to local or remote state
  • LogLevel::INFO - a final decision on an operation that does not change local or remote state
  • LogLevel::DEBUG - extraneous information about the progress of the synchronization process