Fetch Driver Classname
public function onFetchExportDriverClassname(string $driver) : string
Fires while instantiating the requested export driver.
Description
Trigger hook to let the plugins include external export drivers.
The plugins MUST include here all the resources needed to the driver, otherwise it wouldn't be possible to instantiate the returned classes.
The filter should return the PHP class
name related to the requested driver.
In case the specified class doesn't exist, an exception will be thrown. The class MUST extend the VAPOrderExportDriver
abstract class.
NOTE: the file in which the driver class is located should NOT be included.
Parameters
- $driver
-
(string) The name of the driver to include, which is equals to the base name of the file (without
.php
).
Return Value
String. The classname that will be used to instantiate the driver object.
Example
The example below provides the instantiation of the "test" driver located within the VikAppointments - E4J plugin.
/plugins/vikappointments/e4j/drivers/test.php
/**
* Trigger hook to let the plugins include external drivers.
* The plugins MUST include the resources needed, otherwise
* it wouldn't be possible to instantiate the returned classes.
*
* @param string $driver The name of the driver to include.
*
* @return string The classname of the driver object.
*/
public function onFetchExportDriverClassname($driver)
{
if ($driver === 'test')
{
/**
* @todo it is possible to load here external resources...
*/
// return class name for the "test" driver
return 'E4JExportDriverTest';
}
}
The class (shell) of the driver will be built as follows.
class E4JExportDriverTest extends VAPOrderExportDriver
{
/**
* Returns the driver title.
*
* @return string
*/
public function getTitle()
{
return 'E4J - Test';
}
/**
* Returns the driver description.
*
* @return string
*/
public function getDescription()
{
return 'Driver for test purposes';
}
/**
* Override this method to return a list of
* arguments required to driver.
*
* @return array
*/
public function getForm()
{
return array();
}
/**
* Exports the reservations in the given format.
*
* @return string The resulting export string.
*/
public function export()
{
$buffer = '';
/**
* @todo generate string to export
*/
return $buffer;
}
/**
* Downloads the reservations in a file compatible with the given format.
*
* @param string $filename The name of the file that will be downloaded.
*
* @return void
*/
public function download($filename = null)
{
/**
* @todo send headers to download the file
*/
}
}
Changelog
Version | Description |
---|---|
1.7 | Introduced. |