public interface iDatasource

interface.datasource.php #12

This interface describes the minimum a new Datasource type needs to provide to be able to be used by Symphony

Methods

static buildEditor(XMLElement $wrapper, array $errors, string $handle, array $settings)

This function is invoked by the Datasource Editor and allows this Datasource to provide HTML so that it can be created or edited. It is expected that this function will also handle the display of error messages.

Parameters
  • $wrapper XMLElementAn XMLElement for the HTML to be appended to. This is usually AdministrationPage->Form.

  • $errors arrayIf there are any errors, this variable will be an associative array, key being the setting handle.

  • $settings arrayAn associative array of settings. This may be null on create, but will be populated with the Datasource's settings on edit using settings().

  • $handle stringIf the datasource already exists (so it's being edited), the handle of the datasource will be passed to this function.

See Also
XMLElement execute(array $param_pool)

This function is responsible for returning an XMLElement so that the FrontendPage class can add to a page's XML. It is executed and passed the current $param_pool array.

Parameters
  • $param_pool arrayAn associative array of parameters that have been evaluated prior to this Datasource's execution.

Returns

This Datasource should return an XMLElement object.

static string getName()

Returns the human readable name of this Datasource type. This is displayed in the datasource selection options.

string getSource()

This function return the source of this datasource. It's an artefact of old core objects and for the moment it should return the same value as getClass.

static string getTemplate()

Returns the absolute path to the template that this template will use to save instances of this datasource in the DATASOURCES folder.

static string prepare(array $fields, array $parameters, string $template)

Given the settings and any existing datasource parameters, return the contents of this datasource so that can be saved to the file system.

Parameters
  • $fields arrayAn associative array of settings for this datasource, where the key is the name of the setting. These are user defined through the Datasource Editor.

  • $parameters arrayAn associative array of parameters for this datasource, where the key is the name of the parameter.

  • $template stringThe template file, which has already been altered by Symphony to remove any named tokens (ie. <!-- CLASS NAME -->).

Returns

The completed template, ready to be saved.

array settings()

This function returns all the settings of the current Datasource instance.

Returns

An associative array of settings for this datasource where the key is getClass and the value is an associative array of settings, key being the setting name, value being, the value

static boolean validate(array $settings, array $errors)

Given an array of settings, validate them, adding any errors to the $errors variable which is passed by reference. $errors should be formatted as an associative array

Parameters
  • $settings arrayAn associative array of settings

  • $errors arrayPassed as an empty array, can be populated with any validation errors

Returns

true if the datasource is valid, false otherwise. If false it is expected that $errors are populated.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details