Using inheritance correctly
This commit is contained in:
parent
cbe4b093a9
commit
e3077eabca
|
@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
class Checkbox extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = 'date';
|
||||
parent::set_primitive_type('date');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
class Textarea extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = 'date';
|
||||
parent::set_primitive_type('date');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,19 +11,24 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
*/
|
||||
abstract class Field_Type {
|
||||
|
||||
var $primitive_type;
|
||||
private $primitive_type;
|
||||
|
||||
abstract function render( $metadata );
|
||||
|
||||
function validate($value) {
|
||||
public function validate($value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function get_validation_errors() {
|
||||
public function get_validation_errors() {
|
||||
return [];
|
||||
}
|
||||
|
||||
function get_primitive_type(){
|
||||
public function get_primitive_type(){
|
||||
return $this->primitive_type;
|
||||
}
|
||||
|
||||
public function set_primitive_type($primitive_type){
|
||||
$this->primitive_type = $primitive_type;
|
||||
}
|
||||
|
||||
}
|
|
@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
class Numeric extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = 'float';
|
||||
parent::set_primitive_type('float');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
class Radio extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = '';
|
||||
parent::set_primitive_type('');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
class Relationship extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = '';
|
||||
parent::set_primitive_type('');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
class Selectbox extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = '';
|
||||
parent::set_primitive_type('');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
class Text extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = 'string';
|
||||
parent::set_primitive_type('string');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
class Textarea extends Field_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->primitive_type = 'string';
|
||||
parent::set_primitive_type('string');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,11 +8,15 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
|
||||
abstract class Filter_Type extends \Tainacan\Entity {
|
||||
|
||||
var $supported_types = [];
|
||||
private $supported_types = [];
|
||||
|
||||
abstract function render( $metadata );
|
||||
|
||||
function get_supported_types(){
|
||||
public function get_supported_types(){
|
||||
return $this->supported_types;
|
||||
}
|
||||
|
||||
public function set_supported_types($supported_types){
|
||||
$this->supported_types = $supported_types;
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
class List_Filter extends Filter_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->supported_types[] = 'string';
|
||||
parent::set_supported_types(['string']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
class Range extends Filter_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->supported_types = ['float','date'];
|
||||
parent::set_supported_types(['float','date']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue