| 1 |
<?php |
| 2 |
namespace LWS\WOOREWARDS\PointsFlow; |
| 3 |
|
| 4 |
// don't call the file directly |
| 5 |
if( !defined( 'ABSPATH' ) ) exit(); |
| 6 |
|
| 7 |
/** Point export method extends this abstract and are placed in methods/ subdir. */ |
| 8 |
abstract class ExportMethod |
| 9 |
{ |
| 10 |
/** @return (array) the json that will be send, |
| 11 |
* An array with each entries as {email, points} */ |
| 12 |
abstract public function export($value, $arg); |
| 13 |
|
| 14 |
/** @return (string) human readable name */ |
| 15 |
abstract public function getTitle(); |
| 16 |
|
| 17 |
/** @return (string) method identifier */ |
| 18 |
public function getKey() |
| 19 |
{ |
| 20 |
return $this->formatKey($this); |
| 21 |
} |
| 22 |
|
| 23 |
/** @return (array) additionnal argument to pass to export. |
| 24 |
* array is associatvie, only the key is passed to export, value is for display only. */ |
| 25 |
public function getArgs() |
| 26 |
{ |
| 27 |
return array(); |
| 28 |
} |
| 29 |
|
| 30 |
/** allow free user input. |
| 31 |
* If no need of args, should return true */ |
| 32 |
public function supportFreeArgs() |
| 33 |
{ |
| 34 |
return true; |
| 35 |
} |
| 36 |
|
| 37 |
/** @return (bool) appear in method combobox */ |
| 38 |
public function isVisible() |
| 39 |
{ |
| 40 |
return true; |
| 41 |
} |
| 42 |
|
| 43 |
function formatKey($class) |
| 44 |
{ |
| 45 |
if( is_object($class) ) |
| 46 |
$class = get_class($class); |
| 47 |
return str_replace('\\', '_', strtolower($class)); |
| 48 |
} |
| 49 |
|
| 50 |
} |
| 51 |
|